Delphi File and Directory Search Fast Algorithm

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!

+5
source share
10 answers

, , , findfirst/findnext. , . , , .

, , , WinDirStat http://windirstat.info/ ( , , .)
, , . C, , API.

+7

, , , - MFT , NTFS. , , - , , . , , MFT, . , -.

, MFT: WinAPI , . , , , hardlinks, junctions, refparse points, symlinks, shell links ..

, , - .

- Delphi, MFT, , , , . Open Source (GPL) NTFS Undelete, Delphi, MFT Python Delphi-Python.

+5

, Windows (API) .

, .

+2

, "-", , . . , "" .

+1

, , findfirst/findnext, , . , , , .

. "" , ( ). , , , , ( , ). . , (: G:\PROCESSED\2010\06\25\1400 , 14:00 25.06.2010).

, ( , ), , .

+1

Windows 7 Server 2008 R2, FindFirstFileEx, . VCL, .

+1

findfirst/findnext , I/O: !

. , findfirst/findnext, , . , , . , . , , !

, , , - - , ( , OS I/O), findfirst/findnext . , , / HDD, , , -, .

, , SECOND- , prooving I/O, - .

+1

, . , "" () , . , , .

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. ...

+1

, , . , , , . , , , (), , , . , , 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.

0
source

All Articles