Skip to content

Commit

Permalink
Fix TSimbaFile.DirListFiles and DirListFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 24, 2024
1 parent 179ba6f commit 3f40031
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Source/script/imports/simba.import_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('procedure TImage.Pad(Amount: Integer)', @_LapeImage_Pad);
addGlobalFunc('procedure TImage.Offset(X,Y: Integer)', @_LapeImage_Offset);

addGlobalFunc('procedure TImage.SplitChannels(var B,G,R: TByteArray); overload', @_LapeImage_SplitChannels);
addGlobalFunc('procedure TImage.SplitChannels(var B,G,R: TByteArray)', @_LapeImage_SplitChannels);
addGlobalFunc('procedure TImage.FromChannels(const B,G,R: TByteArray; W, H: Integer);', @_LapeImage_FromChannels);

addGlobalFunc('function TImage.GetColors: TColorArray; overload', @_LapeImage_GetColors1);
Expand Down
52 changes: 28 additions & 24 deletions Source/simba.fs.pas
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,21 @@ class function TSimbaDir.DirListFiles(Path: String; Recursive: Boolean): TString
begin
Path := CleanAndExpandDirectory(Path);

if (FindFirst(Path + '*', faAnyFile and faDirectory, SearchRec) = 0) then
repeat
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if (SearchRec.Attr = faDirectory) and Recursive then
Get(Path + SearchRec.Name);

if (SearchRec.Attr <> faDirectory) then
Buffer.Add(Path + SearchRec.Name);
end;
until (FindNext(SearchRec) <> 0);

SysUtils.FindClose(SearchRec);
if (FindFirst(Path + AllFilesMask, faAnyFile and faDirectory, SearchRec) = 0) then
try
repeat
if (SearchRec.Name <> '') and (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if (SearchRec.Attr and faDirectory <> 0) and Recursive then // is directory
Get(Path + SearchRec.Name);

if (SearchRec.Attr and faDirectory = 0) then // is file
Buffer.Add(Path + SearchRec.Name);
end;
until (FindNext(SearchRec) <> 0);
finally
SysUtils.FindClose(SearchRec);
end;
end;

begin
Expand All @@ -178,19 +180,21 @@ class function TSimbaDir.DirListDirectories(Path: String; Recursive: Boolean): T
begin
Path := CleanAndExpandDirectory(Path);

if (FindFirst(Path + '*', faDirectory, SearchRec) = 0) then
repeat
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if (SearchRec.Attr = faDirectory) and Recursive then
Get(Path + SearchRec.Name);
if (FindFirst(Path + AllDirectoryEntriesMask, faDirectory, SearchRec) = 0) then
try
repeat
if (SearchRec.Name <> '') and (SearchRec.Name <> '.') and (SearchRec.Name <> '..') and
(SearchRec.Attr and faDirectory <> 0) then // is directory
begin
if Recursive then
Get(Path + SearchRec.Name);

if (SearchRec.Attr = faDirectory) then
Buffer.Add(Path + SearchRec.Name);
end;
until (FindNext(SearchRec) <> 0);

SysUtils.FindClose(SearchRec);
end;
until (FindNext(SearchRec) <> 0);
finally
SysUtils.FindClose(SearchRec);
end;
end;

begin
Expand Down

0 comments on commit 3f40031

Please sign in to comment.