Talk:is Directory empty/de
From Lazarus wiki
Jump to navigationJump to search
This part:
FindFirst(IncludeTrailingPathDelimiter(strVerzeichnis) + '*', faAnyFile, srDatensatz);
for intI := 1 to 2 do
if (srDatensatz.Name = '.') or (srDatensatz.Name = '..') then
Result := FindNext(srDatensatz) <> 0;
seems to assume that '.' and '..' will always be the first two reported entries by FindFirst/FindNext.
This may not be the case (some filesystems do not support .. (at least that's what the fpc sources suggest)).
I would rewrite that like:
if FindFirst(IncludeTrailingPathDelimiter(strVerzeichnis) + '*', faAnyFile, srDatensatz) = 0 then
repeat
if not ((srDatensatz.Name = '.') or (srDatensatz.Name = '..')) then Result := True;
until Result or (FindNext(srDatensatz) <> 0);