Sign in Join
Wiki copytemporary

is Directory empty/de

Zurück zur Seite Code Beispiele.

Die Funktion ermittelt unter Windows und Linux (Ubuntu) ob das Verzeichnis leer ist:

pascal
uses
  SysUtils;

  ...

function funIstVerzeichnisLeer(strVerzeichnis: string): boolean;
var
  srDatensatz: TSearchRec;
  intI: integer;
begin
  Result := False;

  FindFirst(IncludeTrailingPathDelimiter(strVerzeichnis) + '*', faAnyFile, srDatensatz);

  for intI := 1 to 2 do
    if (srDatensatz.Name = '.') or (srDatensatz.Name = '..') then
      Result := FindNext(srDatensatz) <> 0;

  FindClose(srDatensatz);
end;

Aufruf unter Windows:

pascal
function funTest: string;
begin
  if funIstVerzeichnisLeer('D:\Test') = True then
    Result := 'Leer'
  else
    Result := 'nicht Leer';
end;

Aufruf unter Linux (Ubuntu):

pascal
function funTest: string;
begin
  if funIstVerzeichnisLeer('/home/user/Test') = True then
    Result := 'Leer'
  else
    Result := 'nicht Leer'; 
end;

From the Free Pascal wiki, page "is Directory empty/de", as it stood on 2020-02-18 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.