[gdal-dev] VSIReadDir() and GDALOpenInfo
Andrey Kiselev
dron at ak4719.spb.edu
Thu Jan 31 05:17:30 EST 2008
On Wed, Jan 30, 2008 at 12:00:16PM -0500, Frank Warmerdam wrote:
> But I'm wondering if there is a fundamentally better approach to
> scanning for the list of files in a directory, or if this is
> inherently quite an expensive operation. Thoughts? Other experiences
> on this? Is this more of an issue with particular file systems?
Ulrich Drepper has some insights on the issue:
http://udrepper.livejournal.com/18555.html
Based on his article I see few problems with our code:
1. We are using readdir() instead of readdir64().
2. We are not checking the file type: do we really need to add
subdirectory names to the list?
3. Directory entry names have a fixed length, so we can optimize a bit
by removing CPLStrdup() call.
The only problem is that readdir64() could be not portable enougth, but
this is easy to fix using the same approach as with other *64() calls.
Other than above it seems to be nothing to optimize in our code.
Best regards,
Andrey
--
Andrey V. Kiselev
ICQ# 26871517
More information about the gdal-dev
mailing list