Skip to content

Commit

Permalink
[fix] Added missing FindClose, [+] SubdirectoryCount
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdp committed Aug 14, 2020
1 parent aceca00 commit a20c063
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Base/JPL.Files.pas
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function GetUniqueFileName(Prefix: string = ''; Len: BYTE = 10; Ext: string = ''

function GetFiles(const Directory: string; SearchPattern: string = '*'; RecurseDepth: Word = 0): TStringDynArray;
function GetDirectories(const Directory: string; SearchPattern: string = '*'; RecurseDepth: Word = 0): TStringDynArray;
function SubdirectoryCount(const Directory: string; SearchPattern: string = '*'; RecurseDepth: Word = 0): integer;


implementation
Expand Down Expand Up @@ -162,6 +163,11 @@ function GetDirectories(const Directory: string; SearchPattern: string = '*'; Re
end;
end;

function SubdirectoryCount(const Directory: string; SearchPattern: string = '*'; RecurseDepth: Word = 0): integer;
begin
Result := Length(GetDirectories(Directory, SearchPattern, RecurseDepth));
end;

function GetIncFileName(const fName: string; NumPrefix: string = '_'; xpad: integer = 3): string;
var
i: integer;
Expand Down Expand Up @@ -319,6 +325,7 @@ function FileGetCreationTime(const FileName: string): TDateTime;
FileTimeToLocalFileTime(SearchRec.FindData.ftCreationTime, FileTime);
FileTimeToSystemTime(FileTime, SysTime);
Result := SystemTimeToDateTime(SysTime);
SysUtils.FindClose(SearchRec);
end
else Result := 0;
end;
Expand All @@ -343,6 +350,7 @@ function FileGetTimes(const FileName: string; out CreationTime, LastAccessTime,
FileTimeToSystemTime(FileTime, SysTime);
LastWriteTime := SystemTimeToDateTime(SysTime);

SysUtils.FindClose(SearchRec);
Result := True;
end
else Result := False;
Expand Down

0 comments on commit a20c063

Please sign in to comment.