[Gdal-dev] File extensions

Ray Gardener rayg at daylongraphics.com
Thu Dec 7 00:54:38 EST 2006


Strongly associating filename extensions to file types is a game that 
eventually loses. Some platforms don't mandate them at all, and the ones 
that do, extensions have a many-many relationship to formats (e.g., HDR 
is both a common header file type and the Radiance HDRI type. DEM could 
mean nearly anything, etc.).

fwiw, my approach is to have users explicitly specify filetype, and then 
filename. That way there's never confusion about which driver to use or 
which default extension to use.

If you let driver I/O calls alter filenames, then they're doing more 
than they're supposed to. You don't want routines that generate side 
effects, and filename arguments to I/O funcs should be considered const.

Ray



Matt Hanson wrote:
> Hi,
> 
> I'm using GDAL in an app where I want the user to specify an output
> format and have it be transparent to me in my app (after all, that's
> the point of GDAL).    The problem is that some drivers (including a
> custom one we have written) have specific file extension
> requirements.    When I call Create() I give it a filename.  Now, the
> driver should be smart enough to give it the correct extension if it
> doesn't have one.....but the problem is that I then have no way of
> knowing if the filename has been altered or not.
> 
> So, the problem is that I either: - need to know what the driver is
> so I can give it the appropriate extension...but then that puts
> requirements on me to know the file format type which really is the
> responsibility of GDAL - need to retrieve from GDAL the new name, in
> case it's been altered by the driver, after I create a dataset.  But
> I don't see any method to do this....did I miss something?
> 
> This seems like a very simple problem and perhaps I have overlooked
> something or am not being clever enough.  Anyone else run into this
> issue?
> 
> 
> matt




More information about the Gdal-dev mailing list