/*! \param info Object with information about the dataset to open. \return Pointer to newly allocated GDALDataset or 0. Returns 0 if the file could not be opened. */ GDALDataset* PCRasterDataset::open( GDALOpenInfo* info) { PCRasterDataset* dataset = 0; if(info->fpL && info->nHeaderBytes >= static_cast<int>(CSF_SIZE_SIG) && strncmp((char*)info->pabyHeader, CSF_SIG, CSF_SIZE_SIG) == 0) { MOPEN_PERM mode = info->eAccess == GA_Update ? M_READ_WRITE : M_READ; MAP* map = mapOpen(info->pszFilename, mode); if(map) { dataset = new PCRasterDataset(map); } } /* -------------------------------------------------------------------- */ /* Initialize any PAM information and overviews. */ /* -------------------------------------------------------------------- */ if( dataset ) { dataset->SetDescription( info->pszFilename ); dataset->TryLoadXML(); dataset->oOvManager.Initialize( dataset, info->pszFilename ); } return dataset; }
/*! \param info Object with information about the dataset to open. \return Pointer to newly allocated GDALDataset or 0. Returns a nullptr if the file could not be opened. */ GDALDataset* PCRasterDataset::open( GDALOpenInfo* info) { PCRasterDataset* dataset = NULL; if(info->fpL && info->nHeaderBytes >= static_cast<int>(CSF_SIZE_SIG) && strncmp(reinterpret_cast<char*>( info->pabyHeader ), CSF_SIG, CSF_SIZE_SIG) == 0) { MOPEN_PERM mode = info->eAccess == GA_Update ? M_READ_WRITE : M_READ; MAP* map = mapOpen(info->pszFilename, mode); if(map) { CPLErrorReset(); dataset = new PCRasterDataset(map); if( CPLGetLastErrorType() != CE_None ) { delete dataset; return NULL; } } } /* -------------------------------------------------------------------- */ /* Initialize any PAM information and overviews. */ /* -------------------------------------------------------------------- */ if( dataset ) { dataset->SetDescription( info->pszFilename ); dataset->TryLoadXML(); dataset->oOvManager.Initialize( dataset, info->pszFilename ); } return dataset; }