mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
FIX: Matching file name for a search template.
This commit is contained in:
parent
203301a575
commit
3d8d2b6151
3 changed files with 24 additions and 21 deletions
|
|
@ -80,6 +80,7 @@ type
|
|||
|
||||
TFindFileChecks = record
|
||||
FilesMasks: String;
|
||||
ExcludeFiles: String;
|
||||
RegExp: Boolean;
|
||||
DateTimeFrom,
|
||||
DateTimeTo : TDateTime;
|
||||
|
|
@ -91,6 +92,7 @@ type
|
|||
procedure SearchTemplateToFindFileChecks(const SearchTemplate: TSearchTemplateRec;
|
||||
out FileChecks: TFindFileChecks);
|
||||
|
||||
function CheckFileName(const FileChecks: TFindFileChecks; const FileName: String) : Boolean;
|
||||
function CheckFileTime(const FileChecks: TFindFileChecks; FT : TFileTime) : Boolean; inline;
|
||||
function CheckFileDateTime(const FileChecks: TFindFileChecks; DT : TDateTime) : Boolean;
|
||||
function CheckFileSize(const FileChecks: TFindFileChecks; FileSize : Int64) : Boolean;
|
||||
|
|
@ -99,7 +101,7 @@ type
|
|||
implementation
|
||||
|
||||
uses
|
||||
strutils, DateUtils, DCDateTimeUtils, DCFileAttributes;
|
||||
strutils, DateUtils, DCDateTimeUtils, DCFileAttributes, SynRegExpr, uMasks;
|
||||
|
||||
const
|
||||
cKilo = 1024;
|
||||
|
|
@ -263,12 +265,30 @@ begin
|
|||
FileChecks.FilesMasks := '*' + SearchTemplate.FilesMasks + '*'
|
||||
else
|
||||
FileChecks.FilesMasks := SearchTemplate.FilesMasks;
|
||||
FileChecks.ExcludeFiles := SearchTemplate.ExcludeFiles;
|
||||
FileChecks.RegExp := SearchTemplate.RegExp;
|
||||
DateTimeOptionsToChecks(SearchTemplate, FileChecks);
|
||||
FileSizeOptionsToChecks(SearchTemplate, FileChecks);
|
||||
AttrsPatternOptionsToChecks(SearchTemplate, FileChecks);
|
||||
end;
|
||||
|
||||
function CheckFileName(const FileChecks: TFindFileChecks; const FileName: String): Boolean;
|
||||
begin
|
||||
with FileChecks do
|
||||
begin
|
||||
if RegExp then
|
||||
begin
|
||||
Result := ((FilesMasks = '') or ExecRegExpr(FilesMasks, FileName)) and
|
||||
((ExcludeFiles = '') or not ExecRegExpr(ExcludeFiles, FileName));
|
||||
end
|
||||
else
|
||||
begin
|
||||
Result := MatchesMaskList(FileName, FilesMasks) and
|
||||
not MatchesMaskList(FileName, ExcludeFiles);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function CheckFileTime(const FileChecks: TFindFileChecks; FT : TFileTime) : Boolean;
|
||||
begin
|
||||
Result := CheckFileDateTime(FileChecks, FileTimeToDateTime(FT));
|
||||
|
|
|
|||
|
|
@ -311,27 +311,13 @@ begin
|
|||
end;
|
||||
|
||||
function TFindThread.CheckFile(const Folder : String; const sr : TSearchRecEx) : Boolean;
|
||||
var
|
||||
UpperCaseFileName: String;
|
||||
begin
|
||||
Result := True;
|
||||
|
||||
with FSearchTemplate do
|
||||
begin
|
||||
// check regular expression
|
||||
if RegExp then
|
||||
begin
|
||||
if ((FilesMasks <> '') and not ExecRegExpr(FilesMasks, sr.Name)) or
|
||||
((ExcludeFiles <> '') and ExecRegExpr(ExcludeFiles, sr.Name)) then
|
||||
if not CheckFileName(FFileChecks, UTF8UpperCase(sr.Name)) then
|
||||
Exit(False);
|
||||
end
|
||||
else
|
||||
begin
|
||||
UpperCaseFileName := UTF8UpperCase(sr.Name);
|
||||
if not MatchesMaskList(UpperCaseFileName, FilesMasks) or
|
||||
MatchesMaskList(UpperCaseFileName, ExcludeFiles) then
|
||||
Exit(False);
|
||||
end;
|
||||
|
||||
if (IsDateFrom or IsDateTo or IsTimeFrom or IsTimeTo or IsNotOlderThan) then
|
||||
Result := CheckFileTime(FFileChecks, sr.Time);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ function IsMaskSearchTemplate(const sMask: UTF8String): Boolean; inline;
|
|||
implementation
|
||||
|
||||
uses
|
||||
uMasks, uFileProperty;
|
||||
uFileProperty;
|
||||
|
||||
function IsMaskSearchTemplate(const sMask: UTF8String): Boolean; inline;
|
||||
begin
|
||||
|
|
@ -101,10 +101,7 @@ begin
|
|||
with SearchRecord do
|
||||
begin
|
||||
if (fpName in AFile.SupportedProperties) then
|
||||
begin
|
||||
Result:= MatchesMaskList(AFile.Name, FilesMasks) and
|
||||
not MatchesMaskList(AFile.Name, ExcludeFiles);
|
||||
end;
|
||||
Result := CheckFileName(FileChecks, AFile.Name);
|
||||
|
||||
if Result and (fpModificationTime in AFile.SupportedProperties) then
|
||||
if (IsDateFrom or IsDateTo or IsTimeFrom or IsTimeTo or IsNotOlderThan) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue