From 6132c2ef3066e813acb1237afeca266f32c53a21 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 28 Nov 2009 16:00:34 +0100 Subject: Engine and VFS API cleanup * also split threaded operations into UCoreWorkers.pas * symlinks should be properly resolved now, even in archives * no more relative/absolute path confusion * moved FillDirFiles outside engines, made it more universal --- USearch.pas | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'USearch.pas') diff --git a/USearch.pas b/USearch.pas index ce9416c..9794e4c 100644 --- a/USearch.pas +++ b/USearch.pas @@ -84,7 +84,7 @@ type FRootEngine: TPanelEngine; Wilds: array of string; GUIMutex: TCriticalSection; - procedure Rekurze(StartDir: string); + procedure DoRecurse(StartDir: string); function FindText(FileName: string): boolean; protected FStartPath, FFileMask, FStringFind: string; @@ -889,14 +889,14 @@ begin Wilds[i] := Format('*%s*', [Wilds[i]]); end; - Rekurze(ExcludeTrailingPathDelimiter(FStartPath)); + DoRecurse(ExcludeTrailingPathDelimiter(FStartPath)); SetLength(Wilds, 0); finally Finished := True; end; end; -procedure TSearchThread.Rekurze(StartDir: string); +procedure TSearchThread.DoRecurse(StartDir: string); var LocalList: TList; i, j: integer; Matches, b: boolean; @@ -917,7 +917,7 @@ begin if FEngine.ChangeDir(StartDir) <> 0 then Exit; LocalList := TList.Create; - if FEngine.GetListing(LocalList, True, StartDir) = 0 then begin + if FEngine.GetListing(LocalList, StartDir, True, True, False) = 0 then begin // Processing... StartDir := IncludeTrailingPathDelimiter(StartDir); @@ -932,7 +932,7 @@ begin Matches := True; // Test if the file is on the same FS if Matches and FDontLeaveFS then - Matches := Matches and FEngine.IsOnSameFS(FStartPath, StartDir + FileName); + Matches := Matches and FEngine.IsOnSameFS(FStartPath, StartDir + FileName, True); // File mask test if Matches and (Length(Wilds) > 0) then begin b := False; @@ -946,13 +946,13 @@ begin if Matches and (FBiggerThan > 0) then Matches := Matches and (Data^.Size >= FBiggerThan); // Date limiting if Matches and (FModifiedLast > 0) then - Matches := Matches and (Data^.ModifyTime <= Now) and (Data^.ModifyTime >= Now - FModifiedLast); + Matches := Matches and (Data^.mtime <= Now) and (Data^.mtime >= Now - FModifiedLast); if Matches and (FModifiedNotLast > 0) then - Matches := Matches and ((Data^.ModifyTime > Now) or (Data^.ModifyTime <= Now - FModifiedNotLast)); + Matches := Matches and ((Data^.mtime > Now) or (Data^.mtime <= Now - FModifiedNotLast)); if Matches and (FNotModifiedAfter > 0) then - Matches := Matches and (Data^.ModifyTime <= FNotModifiedAfter); + Matches := Matches and (Data^.mtime <= FNotModifiedAfter); if Matches and (FModifiedBetween1 > 0) and (FModifiedBetween2 > 0) then - Matches := Matches and (Data^.ModifyTime >= FModifiedBetween1) and (Data^.ModifyTime <= FModifiedBetween2); + Matches := Matches and (Data^.mtime >= FModifiedBetween1) and (Data^.mtime <= FModifiedBetween2); // Find text in file if Matches and (Length(FStringFind) > 0) and (not (FEngine is TVFSEngine)) then begin GUIMutex.Acquire; @@ -979,8 +979,8 @@ begin GUIMutex.Release; end; - if Data^.IsDir and ((not FDontLeaveFS) or (FDontLeaveFS and FEngine.IsOnSameFS(FStartPath, StartDir + FileName))) - then Rekurze(IncludeTrailingPathDelimiter(StartDir) + FileName); + if Data^.IsDir and ((not FDontLeaveFS) or (FDontLeaveFS and FEngine.IsOnSameFS(FStartPath, StartDir + FileName, True))) + then DoRecurse(IncludeTrailingPathDelimiter(StartDir) + FileName); // Handle archives if (not Data^.IsDir) and FSearchArchives and (not (FEngine is TVFSEngine)) then begin @@ -992,7 +992,7 @@ begin xEngine.SavePath := StartDir + FileName; FEngine := xEngine; VFSOpenResult := (FEngine as TVFSEngine).VFSOpenEx(IncludeTrailingPathDelimiter(StartDir) + FileName, nil, nil, nil, nil); - if (VFSOpenResult = 0) and (not CancelIt) then Rekurze('/'); + if (VFSOpenResult = 0) and (not CancelIt) then DoRecurse('/'); FEngine := FEngine.ParentEngine; if not (xEngine as TVFSEngine).VFSClose then DebugMsg(['Error closing the engine...']); xEngine.Free; -- cgit v1.2.3