is Directory empty/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: is Directory empty/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur Seite [[code examples/de|Code Beispiele]]. | |
| 2 | + | ||
| 3 | + | Die Funktion ermittelt unter Windows und Linux (Ubuntu) ob das Verzeichnis leer ist: | |
| 4 | + | ||
| 5 | + | ``` pascal | |
| 6 | + | uses | |
| 7 | + | SysUtils; | |
| 8 | + | ||
| 9 | + | ... | |
| 10 | + | ||
| 11 | + | function funIstVerzeichnisLeer(strVerzeichnis: string): boolean; | |
| 12 | + | var | |
| 13 | + | srDatensatz: TSearchRec; | |
| 14 | + | intI: integer; | |
| 15 | + | begin | |
| 16 | + | Result := False; | |
| 17 | + | ||
| 18 | + | FindFirst(IncludeTrailingPathDelimiter(strVerzeichnis) + '*', faAnyFile, srDatensatz); | |
| 19 | + | ||
| 20 | + | for intI := 1 to 2 do | |
| 21 | + | if (srDatensatz.Name = '.') or (srDatensatz.Name = '..') then | |
| 22 | + | Result := FindNext(srDatensatz) <> 0; | |
| 23 | + | ||
| 24 | + | FindClose(srDatensatz); | |
| 25 | + | end; | |
| 26 | + | ``` | |
| 27 | + | ||
| 28 | + | Aufruf unter Windows: | |
| 29 | + | ||
| 30 | + | ``` pascal | |
| 31 | + | function funTest: string; | |
| 32 | + | begin | |
| 33 | + | if funIstVerzeichnisLeer('D:\Test') = True then | |
| 34 | + | Result := 'Leer' | |
| 35 | + | else | |
| 36 | + | Result := 'nicht Leer'; | |
| 37 | + | end; | |
| 38 | + | ``` | |
| 39 | + | ||
| 40 | + | Aufruf unter Linux (Ubuntu): | |
| 41 | + | ||
| 42 | + | ``` pascal | |
| 43 | + | function funTest: string; | |
| 44 | + | begin | |
| 45 | + | if funIstVerzeichnisLeer('/home/user/Test') = True then | |
| 46 | + | Result := 'Leer' | |
| 47 | + | else | |
| 48 | + | Result := 'nicht Leer'; | |
| 49 | + | end; | |
| 50 | + | ``` | |
| 51 | + | ||
| 52 | + | --- | |
| 53 | + | *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](/wiki-contact).* |
