Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File Search
Message
From
12/01/1999 00:48:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
11/01/1999 20:13:05
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00174916
Message ID:
00174941
Views:
21
>Hello everyone!
>
>Does anyone tried to implement something like file search in VFP.
>
>The situation is simple. Project I'm working on requres to check selected drives by directories tree and find all files with certain mask. For example I need to find all *.pjx on developer computer and build, let's say tree or list of all occurenses. Please, show me the better way how to do it.
function findfile
lparameters startdir, cfilename
start=seconds()
set talk off
mtopdir=sys(5)+curdir()
create cursor filelist ;
  (directory m, filename c(40), filesize i,filedate d,fileattr c(5))
set defa to (startdir)
PUBLIC ARRAY DIRLIST[1,2]
=GETSUBDIRS()
for ix=1 to alen(dirlist,1)
	=checkfile(dirlist[ix,1],cFileName)
endfor
set defa to (mtopdir)
? seconds()-start, alen(dirlist,1) 
browse
return

***********************************************************************
* GETSUBDIRS : COLLECT SUBDIRECTORY NAMES INTO ARRAY <DIRLIST>
***********************************************************************
FUNCTION GETSUBDIRS
dirlist[1,1]=curdir()
apos=ascan(dirlist,.f.)
do while apos>0
	crow=asubscript(dirlist,apos,1)
	set default to trim(dirlist[crow,1])
	dirlist[crow,2]=.t.
	=putsubs()
	apos=ascan(dirlist,.f.)
enddo

***********************************************************************
* PUTSUBS : COLLECT SUBDIRECTORY NAMES OF CURRENT DIRECTORY 
*			INTO PUBLIC ARRAY <DIRLIST>
***********************************************************************
function putsubs
mcurdir=sys(5)+curdir()
subcnt=adir(dirs,"","D")
if subcnt>0
	for dirc=1 to subcnt
		if dirs[dirc,1]="."
			loop
		endif	
		dimension dirlist[alen(dirlist,1)+1,2]
		dirlist[alen(dirlist,1),1]=mcurdir+dirs[dirc,1]
	endfor
endif

***************************************************************************
* CHECKFILE : CHECK cFileName in cDirectory and insert into cursor filelist
***************************************************************************
function checkfile
lparameters cDirectory,cFileName
private aDirectory, ix
nFileCnt = adir(aDirectory,cDirectory+iif(right(cDirectory,1)#"\","\","")+cFilename)
if  nFilecnt > 0
	for ix=1 to alen(aDirectory,1)
		insert into filelist values (cDirectory,aDirectory[ix,1],aDirectory[ix,2],aDirectory[ix,3],aDirectory[ix,4])
	endfor
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform