Cześć kodu usefulfunctions
Cześć kodu unit usefulfunctions, na potrzeby function IsDirectoryEmptyuser_6919294
pascal
a year ago
1.7 kB
17
Indexable
// Ireneusz A.
// Moje przydatne funkcje, przydaja sie do innych projektów
// Pisane pod Delphi
unit usefulfunctions;
interface
uses
System.SysUtils, System.IOUtils;
// funkcja sprawdza czy katolog nie jest pusty, brak jakichkolwiek plikow
function IsDirectoryEmpty(const Directory: string): Boolean; overload;
// to samo ale dodajemy maske plikow
function IsDirectoryEmpty(const Directory, FileMask: string): Boolean; overload;
implementation
function IsDirectoryEmpty(const Directory: string): Boolean;
var
SearchRec: TSearchRec;
Found: Integer;
begin
Result := True;
if not DirectoryExists(Directory) then
Exit;
Found := FindFirst(IncludeTrailingPathDelimiter(Directory) + '*', faAnyFile, SearchRec);
try
while Found = 0 do
begin
// Ignore '.' and '..'
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
Result := False;
Break;
end;
Found := FindNext(SearchRec);
end;
finally
FindClose(SearchRec);
end;
end;
function IsDirectoryEmpty(const Directory, FileMask: string): Boolean;
var
SearchRec: TSearchRec;
Found: Integer;
begin
Result := True;
if not DirectoryExists(Directory) then
Exit;
Found := FindFirst(IncludeTrailingPathDelimiter(Directory) + FileMask, faAnyFile, SearchRec);
try
while Found = 0 do
begin
// Ignore '.' and '..'
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
Result := False;
Break;
end;
Found := FindNext(SearchRec);
end;
finally
FindClose(SearchRec);
end;
end;
end.Editor is loading...