What's wrong with just always doing the stat?
Nothing, but just one extra system call in a performance critical path.
Or, if it's really important to avoid the stat, put the code that makes
beyond-POSIX assumptions under #ifdef linux.   Then we'd have code that
is in general correct, and avoids a stat on systems known to not return
any bytes on a directory.

I basically whitelisted OSs that are tested by our CI and for which fread() on a directory FILE* returns 0 and where we can save the stat() when it is a non-empty file, which is the nominal case for most GDAL usage.

--
http://www.spatialys.com
My software is free, but my time generally not.

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to