[Gdal-dev] VSI file open/close issue

Frank Warmerdam warmerdam at pobox.com
Fri Aug 25 09:50:07 EDT 2006


Frederic Claudel wrote:
> When using VSI* or VSI*L functions, it seems impossible to mix both, which
> means opening a file using VSIFOpen then closing it with VSIFCloseL.
> 
> Hence my question : how can I tell them apart ? In a new GDAL driver where I
> need to open lots of datasets, I'd like to re-use the opened file descriptor
> included in GDALOpenInfo to avoid unnecessary IO.
> 
> But that file descriptor can be opened by either of VSIFOpen or VSIFOpenL
> (when VSIFOpen fails) - by the way it's always closed using VSIFClose
> Should I use a RTTI function to guess the actual type?

Frederic,

Currently there is no way to distinguish VSI* from VSI*L handles.

However, the "fp" in the GDALOpenInfo is always a VSI* handle.  Drivers
that use VSI*L handes ignore the fp in the GDALOpenInfo and re-open the
file.  Files that don't successfully open with VSIFOpen() (ie. large files
on some systems) are opened with VSIFOpenL(), the header read, and then are
closed again.

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