Difference between revisions of "is Directory empty/de"
From Free Pascal wiki
Jump to navigationJump to searchm |
m (Fixed syntax highlighting; deleted category included in page template) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{is Directory empty}} | {{is Directory empty}} | ||
− | + | ||
− | + | ||
+ | Zurück zur Seite [[code examples/de|Code Beispiele]]. | ||
+ | |||
+ | |||
Die Funktion ermittelt unter Windows und Linux (Ubuntu) ob das Verzeichnis leer ist: | Die Funktion ermittelt unter Windows und Linux (Ubuntu) ob das Verzeichnis leer ist: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
uses | uses | ||
SysUtils; | SysUtils; | ||
Line 13: | Line 17: | ||
srDatensatz: TSearchRec; | srDatensatz: TSearchRec; | ||
intI: integer; | intI: integer; | ||
− | |||
begin | begin | ||
− | |||
Result := False; | Result := False; | ||
Line 25: | Line 27: | ||
FindClose(srDatensatz); | FindClose(srDatensatz); | ||
− | |||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
+ | |||
Aufruf unter Windows: | Aufruf unter Windows: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
function funTest: string; | function funTest: string; | ||
begin | begin | ||
− | |||
if funIstVerzeichnisLeer('D:\Test') = True then | if funIstVerzeichnisLeer('D:\Test') = True then | ||
Result := 'Leer' | Result := 'Leer' | ||
else | else | ||
Result := 'nicht Leer'; | Result := 'nicht Leer'; | ||
− | |||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | ||
Aufruf unter Linux (Ubuntu): | Aufruf unter Linux (Ubuntu): | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
function funTest: string; | function funTest: string; | ||
begin | begin | ||
− | |||
if funIstVerzeichnisLeer('/home/user/Test') = True then | if funIstVerzeichnisLeer('/home/user/Test') = True then | ||
Result := 'Leer' | Result := 'Leer' | ||
else | else | ||
Result := 'nicht Leer'; | Result := 'nicht Leer'; | ||
− | |||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 08:06, 18 February 2020
│
Deutsch (de) │
Zurück zur Seite Code Beispiele.
Die Funktion ermittelt unter Windows und Linux (Ubuntu) ob das Verzeichnis leer ist:
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:
function funTest: string;
begin
if funIstVerzeichnisLeer('D:\Test') = True then
Result := 'Leer'
else
Result := 'nicht Leer';
end;
Aufruf unter Linux (Ubuntu):
function funTest: string;
begin
if funIstVerzeichnisLeer('/home/user/Test') = True then
Result := 'Leer'
else
Result := 'nicht Leer';
end;