CPLErr ELASRasterBand::IWriteBlock( int nBlockXOff, int nBlockYOff, void * pImage ) { ELASDataset *poGDS = (ELASDataset *) poDS; CPLErr eErr = CE_None; long nOffset; int nDataSize; CPLAssert( nBlockXOff == 0 ); CPLAssert( eAccess == GA_Update ); nDataSize = GDALGetDataTypeSize(eDataType) * poGDS->GetRasterXSize() / 8; nOffset = poGDS->nLineOffset * nBlockYOff + 1024 + (nBand-1) * nDataSize; if( VSIFSeek( poGDS->fp, nOffset, SEEK_SET ) != 0 || VSIFWrite( pImage, 1, nDataSize, poGDS->fp ) != (size_t) nDataSize ) { CPLError( CE_Failure, CPLE_FileIO, "Seek or write of %d bytes at %ld failed.\n", nDataSize, nOffset ); eErr = CE_Failure; } return eErr; }
CPLErr ELASRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * pImage ) { ELASDataset *poGDS = (ELASDataset *) poDS; CPLErr eErr = CE_None; long nOffset; int nDataSize; CPLAssert( nBlockXOff == 0 ); nDataSize = GDALGetDataTypeSize(eDataType) * poGDS->GetRasterXSize() / 8; nOffset = poGDS->nLineOffset * nBlockYOff + 1024 + (nBand-1) * nDataSize; /* -------------------------------------------------------------------- */ /* If we can't seek to the data, we will assume this is a newly */ /* created file, and that the file hasn't been extended yet. */ /* Just read as zeros. */ /* -------------------------------------------------------------------- */ if( VSIFSeek( poGDS->fp, nOffset, SEEK_SET ) != 0 || VSIFRead( pImage, 1, nDataSize, poGDS->fp ) != (size_t) nDataSize ) { CPLError( CE_Failure, CPLE_FileIO, "Seek or read of %d bytes at %ld failed.\n", nDataSize, nOffset ); eErr = CE_Failure; } return eErr; }