LazUtils: Revert the big TMask change. It must be worked on later.

git-svn-id: trunk@64675 -
This commit is contained in:
juha 2021-02-27 09:15:16 +00:00
parent 433bb3d412
commit 401d451c71
4 changed files with 501 additions and 958 deletions

View File

@ -795,8 +795,12 @@ var
// Deal with both files and directories
if (PathInfo.Attr and faDirectory) = 0 then
begin // File
if (MaskList = nil) or MaskList.Matches(PathInfo.Name) then
begin
{$IFDEF Windows}
if (MaskList = nil) or MaskList.MatchesWindowsMask(PathInfo.Name)
{$ELSE}
if (MaskList = nil) or MaskList.Matches(PathInfo.Name)
{$ENDIF}
then begin
FPath := APath;
FLevel := ALevel;
FFileInfo := PathInfo;
@ -844,9 +848,14 @@ var
i: Integer;
Dir: String;
OtherDir: String;
MaskOptions: TMaskOptions;
begin
if FSearching then RaiseSearchingError;
MaskList := TMaskList.CreateSysNative(ASearchMask, FMaskSeparator, CaseSensitive);
if CaseSensitive then
MaskOptions := [moCaseSensitive]
else
MaskOptions := [];
MaskList := TMaskList.Create(ASearchMask, FMaskSeparator, MaskOptions);
// empty mask = all files mask
if MaskList.Count = 0 then
FreeAndNil(MaskList);

View File

@ -16,6 +16,7 @@ interface
resourceString
lrsModified = ' modified ';
lrsInvalidCharSet = 'The char set in mask "%s" is not valid!';
lrsSize = ' size ';
lrsFileDoesNotExist = 'file "%s" does not exist';
lrsFileIsADirectoryAndNotAnExecutable = 'file "%s" is a directory and not an'
@ -41,15 +42,6 @@ resourceString
lrsERRORInCode = 'ERROR in code: ';
lrsCreatingGdbCatchableError = 'Creating gdb catchable error:';
// Masks
rsInvalidCharMaskAt = 'Invalid char mask "%s" at %d';
rsInvalidCharMask = 'Invalid char mask "%s"';
rsMissingCloseCharMaskAt = 'Missing close char mask "%s" at %d';
rsMissingCloseCharMask = 'Missing close char mask "%s"';
rsIncompleteMask = 'Reached end of mask, but missing close/escape sequence.';
rsInvalidEscapeChar = 'Escape character must be ASCII <= 127';
rsInternalError = 'Internal %s error.';
// XPath
lrsNodeSet = 'node set';
lrsBoolean = 'boolean';

File diff suppressed because it is too large Load Diff

View File

@ -675,12 +675,12 @@ procedure GetFilesInDir(const ABaseDir: string; AMask: string;
var
DirInfo: TSearchRec;
FindResult, i: Integer;
IsDirectory, IsValidDirectory, IsHidden, AddFile: Boolean;
IsDirectory, IsValidDirectory, IsHidden, AddFile, UseMaskList: Boolean;
SearchStr, ShortFilename: string;
MaskList: TMaskList;
Files: TList;
FileItem: TFileItem;
CaseSens: Boolean;
MaskOptions: TMaskOptions;
{$if defined(windows) and not defined(wince)}
ErrMode : LongWord;
{$endif}
@ -696,26 +696,50 @@ begin
Delete(AMask, Length(AMask), 1);
if Trim(AMask) = '' then
AMask := AllFilesMask;
{$ifdef NotLiteralFilenames}
CaseSens := ACaseSensitivity = mcsCaseSensitive;
{$else}
CaseSens := ACaseSensitivity <> mcsCaseInsensitive;
{$endif}
MaskList := TMaskList.Create(AMask, ';', CaseSens);
//Use a TMaksList if more than 1 mask is specified or if MaskCaseSensitivity differs from the platform default behaviour
UseMaskList := (Pos(';', AMask) > 0) or
{$ifdef NotLiteralFilenames}
(ACaseSensitivity = mcsCaseSensitive)
{$else}
(ACaseSensitivity = mcsCaseInsensitive)
{$endif}
;
if UseMaskList then
begin
//Disable the use of sets in the masklist.
//this behaviour would be incompatible with the situation if no MaskList was used
//and it would break backwards compatibilty and could raise unexpected EConvertError where it did not in the past.
//If you need sets in the MaskList, use the OnAddItem event for that. (BB)
MaskOptions := [moDisableSets];
{$ifdef NotLiteralFilenames}
if (ACaseSensitivity = mcsCaseSensitive) then
MaskOptions := [moDisableSets, moCaseSensitive];
{$else}
if (ACaseSensitivity <> mcsCaseInsensitive) then
MaskOptions := [moDisableSets, moCaseSensitive];
{$endif}
MaskList := TMaskList.Create(AMask, ';', MaskOptions); //False by default
end;
try
if AFileSortType = fstNone then
Files:=nil
else
Files := TList.Create;
i := 0;
SearchStr := IncludeTrailingPathDelimiter(ABaseDir) + AllFilesMask;
if UseMaskList then
SearchStr := IncludeTrailingPathDelimiter(ABaseDir) + AllFilesMask
else
SearchStr := IncludeTrailingPathDelimiter(ABaseDir) + AMask; //single mask, let FindFirst/FindNext handle matching
FindResult := FindFirstUTF8(SearchStr, faAnyFile, DirInfo);
while (FindResult = 0) do
begin
ShortFilename := DirInfo.Name;
IsValidDirectory := (ShortFilename <> '.') and (ShortFilename <> '..');
//no need to call MaskListMatches (which loops through all masks) if ShortFileName is '.' or '..' since we never process this
if MaskList.Matches(DirInfo.Name) and IsValidDirectory then
if ((not UseMaskList) or MaskList.Matches(DirInfo.Name)) and IsValidDirectory then
begin
inc(i);
if i = 100 then