1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114:
|
const szFormat = 'yyyy/mm/dd hh:nn:ss';
{$IFDEF DEBUG_SHOWTIME} var iFile : integer = 0; iFolder : integer = 0; dwStart : dword; {$ENDIF}
procedure FindFiles(const orgpath: string; const FindMask: TStringList; ResultPath, ResultDateTime, ResultFiles: TStrings; const fUseList:boolean=false); var path : string; {$IFNDEF USE_REPEAT} res : integer; {$ENDIF} ds : TSearchRec; begin if(orgpath = '') or (FindMask = nil) or (FindMask.Count = 0) or (ResultPath = nil) or (ResultDateTime = nil) or (ResultFiles = nil) then exit; GetDir(0,path);
{$IFDEF USE_REPEAT} if(FindFirst('*.*',faAnyFile,ds) = 0) then repeat {$ELSE} res := FindFirst('*.*',faAnyFile,ds); while(res = 0) do begin {$ENDIF} if(ds.Attr and faDirectory = 0) and (ds.Name <> '.') and (ds.Name <> '..') then begin {$IFDEF DEBUG_SHOWTIME} inc(iFile); {$ENDIF}
if((not fUseList) and (FindMask.IndexOf(ExtractFileExt(ds.Name)) = -1)) or ((fUseList) and (FindMask.IndexOf(ExtractFileExt(ds.Name)) <> -1)) then begin ResultPath.Add(path);
ResultDateTime.Add(FormatDateTime('' , FileDateToDateTime(ds.Time)));
ResultFiles.Add(ds.Name); end;
end; {$IFDEF USE_REPEAT} until(FindNext(ds) <> 0); {$ELSE} res := FindNext(ds); end; {$ENDIF} FindClose(ds);
{$IFDEF USE_REPEAT} if(FindFirst('*.*',faDirectory,ds) = 0) then repeat {$ELSE} res := FindFirst('*.*',faDirectory,ds); while(res = 0) do begin {$ENDIF} if(ds.Attr and faDirectory <> 0) and (ds.Name <> '.') and (ds.Name <> '..') then begin {$IFDEF DEBUG_SHOWTIME} inc(iFolder); {$ENDIF}
ChDir (ds.Name); FindFiles(orgPath, FindMask, ResultPath, ResultDateTime, ResultFiles, fUseList); end; {$IFDEF USE_REPEAT} until(FindNext(ds) <> 0); {$ELSE} res := FindNext(ds); end; {$ENDIF} FindClose(ds);
if(CompareText(path,orgpath) <> 0) then ChDir('..'); end; |