[Gdal-dev] Glitch with gml driver on windows

Roger James rogerjames99 at btinternet.com
Wed May 7 09:07:23 EDT 2003


Frank,

I think the following code snippet from gmlreader.cpp (line 597) has a
problem on windows. It's the old cr/lf thing.

    if( VSIFRead( pszWholeText, nLength, 1, fp ) != 1 )
    {
        VSIFree( pszWholeText );
        VSIFClose( fp );
        CPLError( CE_Failure, CPLE_AppDefined, 
                  "Read failed on %s.", pszFile );
        return FALSE;
    }

This will always fail on windos because the file has been opened in text
mode and crlf translation is taking place. You have calculated nLength
by using the position pointers, which give the length on disk including
lf chars. VSIFRead calls fread which calculates its read length after
the lf chars have been stripped. This means this piece of code always
detects a failure and the reader goes on to create another gfs file,
which it then fails to save because one already exists.

I cannot think of an easy clean fix for this one without prescanning the
file. The dirty way is to ignore the test on windos systems.

Roger




More information about the Gdal-dev mailing list