[fpc-pascal] FindFirst/FindNex question

Tomas Hajny XHajT03 at hajny.biz
Sun Sep 13 19:26:11 CEST 2026


On 2026-09-13 17:22, Bart via fpc-pascal wrote:
> Hi,
> 
> Just curious.
> 
> Given a situation where FindFirst/FindNext returns 0 (=succes), under
> which circumstance can the TSearchRec.Name become an empty string?
> 
> I'm asking because we have code in our codebase (fpc/lazarus) like:
> 
> =======
>   if FindFirst(CurSrcDir+AllFilesMask,DeleteMask,FileInfo)=0 then
>     Try
>       repeat
>         // check if special file
>         if (FileInfo.Name='.') or (FileInfo.Name='..') or
> (FileInfo.Name='') then
>           continue;
> ========
> 
> Never saw that on Windows or Linux, but since fpc supports more
> platforms, maybe some of them may return an ampty string for
> TSearchRec.Name?

I don't pretend knowing behaviour of all platforms supported by FPC, but 
I don't think that it should happen. However, you don't show the end of 
the repeat until cycle - depending on the exact condition there, the 
check might be relevant for the repetitions (not that I'd expect it, 
just for completeness sake).

Tomas


More information about the fpc-pascal mailing list