[gdal-dev] VSIReadDir() and GDALOpenInfo
Frank Warmerdam
warmerdam at pobox.com
Thu Jan 31 10:12:27 EST 2008
Andrey Kiselev wrote:
> 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().
Andrey,
In the VSIReadDir() code we do not actually consult the file size so
I don't see any requirement to complicate things with the 64bit variant.
> 2. We are not checking the file type: do we really need to add
> subdirectory names to the list?
Yes, the sibling list should contain all normal files, special files
and directories.
> 3. Directory entry names have a fixed length, so we can optimize a bit
> by removing CPLStrdup() call.
Memory still needs to be dynamically allocated for the entry in the list
returned from ReadDir() so I don't see what you are getting at.
> Other than above it seems to be nothing to optimize in our code.
It was an informative article though I'm left with the same conclusion.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the gdal-dev
mailing list