Changeset 14719

Show
Ignore:
Timestamp:
06/17/08 17:19:41 (6 months ago)
Author:
rouault
Message:

RawRasterBand? : add extra parameter bOwnsFP to enable the RawRasterBand? to take ownership of the fpRaw so as to close it properly in its destructor

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/frmts/raw/rawdataset.cpp

    r14675 r14719  
    4242                              int nPixelOffset, int nLineOffset, 
    4343                              GDALDataType eDataType, int bNativeOrder, 
    44                               int bIsVSIL
     44                              int bIsVSIL, int bOwnsFP
    4545 
    4646{ 
     
    5151    this->eDataType = eDataType; 
    5252    this->bIsVSIL = bIsVSIL; 
     53    this->bOwnsFP =bOwnsFP; 
    5354 
    5455    this->fpRaw = fpRaw; 
     
    8687                              int nPixelOffset, int nLineOffset, 
    8788                              GDALDataType eDataType, int bNativeOrder, 
    88                               int nXSize, int nYSize, int bIsVSIL
     89                              int nXSize, int nYSize, int bIsVSIL, int bOwnsFP
    8990 
    9091{ 
     
    9596    this->eDataType = eDataType; 
    9697    this->bIsVSIL = bIsVSIL; 
     98    this->bOwnsFP =bOwnsFP; 
    9799 
    98100    this->fpRaw = fpRaw; 
     
    153155 
    154156    FlushCache(); 
     157     
     158    if (bOwnsFP) 
     159    { 
     160        if ( bIsVSIL ) 
     161            VSIFCloseL( fpRaw ); 
     162        else 
     163            VSIFClose( fpRaw ); 
     164    } 
    155165     
    156166    CPLFree( pLineBuffer ); 
  • trunk/gdal/frmts/raw/rawdataset.h

    r14675 r14719  
    8181 
    8282    char           **papszCategoryNames; 
     83     
     84    int         bOwnsFP; 
    8385 
    8486    int         Seek( vsi_l_offset, int ); 
     
    101103                                int nLineOffset, 
    102104                                GDALDataType eDataType, int bNativeOrder, 
    103                                 int bIsVSIL = FALSE ); 
     105                                int bIsVSIL = FALSE, int bOwnsFP = FALSE ); 
    104106 
    105107                 RawRasterBand( FILE * fpRaw,  
     
    107109                                int nLineOffset, 
    108110                                GDALDataType eDataType, int bNativeOrder, 
    109                                 int nXSize, int nYSize, int bIsVSIL = FALSE ); 
     111                                int nXSize, int nYSize, int bIsVSIL = FALSE, int bOwnsFP = FALSE ); 
    110112 
    111113                 ~RawRasterBand(); 
     
    138140    int          GetIsVSIL() { return bIsVSIL; } 
    139141    FILE        *GetFP() { return fpRaw; } 
     142    int          GetOwnsFP() { return bOwnsFP; } 
    140143}; 
    141144