I am using Delphi7 and I need a solution to a big problem. Can someone provide me a faster way to search for files and folders than using findnext and findfirst? because I also process the data for each file / folder (creation date / author / size / etc.) and it takes a lot of time ... I searched a lot under WinApi, but probably I do not see the best function in to accomplish this. All the examples I found in Delphi use findfirst and findnext ...
In addition, I do not want to buy components or use some free ...
Thanks in advance!
, , , findfirst/findnext. , . , , .
, , , WinDirStat http://windirstat.info/ ( , , .), , . C, , API.
, , , - MFT , NTFS. , , - , , . , , MFT, . , -.
, MFT: WinAPI , . , , , hardlinks, junctions, refparse points, symlinks, shell links ..
, , - .
- Delphi, MFT, , , , . Open Source (GPL) NTFS Undelete, Delphi, MFT Python Delphi-Python.
, Windows (API) .
, .
, "-", , . . , "" .
, , findfirst/findnext, , . , , , .
. "" , ( ). , , , , ( , ). . , (: G:\PROCESSED\2010\06\25\1400 , 14:00 25.06.2010).
, ( , ), , .
Windows 7 Server 2008 R2, FindFirstFileEx, . VCL, .
findfirst/findnext , I/O: !
. , findfirst/findnext, , . , , . , . , , !
, , , - - , ( , OS I/O), findfirst/findnext . , , / HDD, , , -, .
, , SECOND- , prooving I/O, - .
, . , "" () , . , , .
TMyScanThread
, "" + TList/TStringList Syncronize(). () , OS .
PseudoCode :
TMyScanThread=class(TThread) private fCount : Cardinal; fLastFile : String; procedure GetListCount; procedure AddToList; public FileList : TStringList; procedure Execute; Override; end; procedure TMyScanThread.GetListCount; begin fCount := FileList.Count; end; procedure TMyScanThread.AddToList; begin FileList.Add(fLastFile); end; procedure TMyScanThread.Execute; begin try { Get the list size } Syncronize( GetListCount ); if fCount<500 then begin // FindFirst code goes here { Add a file to the list } fLastFile := SR.Name; // Store Filename in local var Syncronize( AddToList ); // Call method to add to list SleepEx(0,True); end else SleepEx(1000,True); finally Terminate; end; end;
TMyProcessFilesThread
. DB.
Syncronized, .
Syncronize() TCriticalSection. ...
BFS vs. DFS. .
http://blogs.msdn.com/b/ericlippert/archive/2004/09/27/234826.aspx
http://en.wikipedia.org/wiki/Breadth-first_search
http://en.wikipedia.org/wiki/Depth-first_search
, , . , , , . , , , (), , , . , , Select. : * , author = 'bob' size > 10000
I am not sure if this approach will help you. Could you tell us more about what you do with these files and search criteria.