Changeset 13994

Show
Ignore:
Timestamp:
03/13/08 11:15:18 (2 months ago)
Author:
warmerdam
Message:

support NDF2 files in other than the current directory (#2274)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.5/gdal/frmts/raw/ndfdataset.cpp

    r11465 r13994  
    247247    { 
    248248        char szKey[100]; 
    249         const char *pszFilename; 
     249        CPLString osFilename; 
    250250 
    251251        sprintf( szKey, "BAND%d_FILENAME", iBand+1 ); 
    252         pszFilename = poDS->Get(szKey,NULL); 
     252        osFilename = poDS->Get(szKey,""); 
    253253 
    254254        // NDF1 file do not include the band filenames. 
    255         if( pszFilename == NULL
     255        if( osFilename.size() == 0
    256256        { 
    257257            char szBandExtension[15]; 
    258258            sprintf( szBandExtension, "I%d", iBand+1 ); 
    259             pszFilename = CPLResetExtension( poOpenInfo->pszFilename,  
    260                                             szBandExtension ); 
     259            osFilename = CPLResetExtension( poOpenInfo->pszFilename,  
     260                                            szBandExtension ); 
    261261        } 
    262  
    263         FILE *fpRaw = VSIFOpenL( pszFilename, "rb" ); 
     262        else 
     263        {       
     264            CPLString osBasePath = CPLGetPath(poOpenInfo->pszFilename); 
     265            osFilename = CPLFormFilename( osBasePath, osFilename, NULL); 
     266        } 
     267 
     268        FILE *fpRaw = VSIFOpenL( osFilename, "rb" ); 
    264269        if( fpRaw == NULL ) 
    265270        { 
    266271            CPLError( CE_Failure, CPLE_AppDefined,  
    267272                      "Failed to open band file: %s",  
    268                       pszFilename ); 
     273                      osFilename.c_str() ); 
    269274            delete poDS; 
    270275            return NULL; 
     
    272277        poDS->papszExtraFiles =  
    273278            CSLAddString( poDS->papszExtraFiles,  
    274                           pszFilename ); 
     279                          osFilename ); 
    275280 
    276281        RawRasterBand *poBand =