[Gdal-dev] GDALOpenInfo->fp == NULL for large files?

Nick Bower nick at nickbower.com
Mon Mar 12 04:41:23 EDT 2007


I'm trying to debug the L1B driver - it's failing because poOpenInfo->fp 
is NULL (starting a driver with this test is also in the driver 
tutorial, and a raw driver also):

GDALDataset *L1BDataset::Open( GDALOpenInfo * poOpenInfo )

{
    int i = 0;
    if( poOpenInfo->fp == NULL )
        return NULL; // Returns for no reason
etc...

So I tried to figure out why fp is NULL.  The reason may be below?  I'm 
not a C/C++ programmer to full understand this, so I can only get as far 
as suspecting the problem has something to do with VSIFOpen/VSIFOpenL 
conventions (let me know if I'm off).  With the latter, it is set to 
NULL after reading for some reason, thus meaning (as far as i can tell) 
the L1B, HDF4, raw etc drivers return in the first couple of lines of 
initialization.  The file itself is only 85 Meg, so is not actually that 
large.


GDALOpenInfo

            fp = VSIFOpen( pszFilename, "rb" );

            if( fp != NULL )
            {
                nHeaderBytes = (int) VSIFRead( pabyHeader, 1, 1024, fp );

                VSIRewind( fp );
            }
            else if( errno == 27 /* "File to large" */
                     || errno == ENOENT
                     || errno == 79 /* EOVERFLOW - value too large */ )
            {
                fp = VSIFOpenL( pszFilename, "rb" );
                if( fp != NULL )
                {
                    nHeaderBytes = (int) VSIFReadL( pabyHeader, 1, 1024, 
fp );
                    VSIFCloseL( fp );
                    fp = NULL;
                }
            }






More information about the Gdal-dev mailing list