Merge pull request #5973 from rouault/fix_5970
netCDF: fix 2 issues with netCDF 4.9.0 of msys2-mingw64 (fixes #5970)
This commit is contained in:
commit
5f6ed12447
|
@ -75,8 +75,12 @@
|
|||
|
||||
#define ROTATED_POLE_VAR_NAME "rotated_pole"
|
||||
|
||||
// Detect netCDF 4.8
|
||||
#ifdef NC_ENCZARR
|
||||
// netCDF 4.8 switched to expecting filenames in UTF-8 on Windows
|
||||
// But with netCDF 4.9 and https://github.com/Unidata/netcdf-c/pull/2277/,
|
||||
// this is apparently back to expecting filenames in current codepage...
|
||||
// Detect netCDF 4.8 with NC_ENCZARR
|
||||
// Detect netCDF 4.9 with NC_NOATTCREORD
|
||||
#if defined(NC_ENCZARR) && !defined(NC_NOATTCREORD)
|
||||
#define NETCDF_USES_UTF8
|
||||
#endif
|
||||
|
||||
|
@ -9412,6 +9416,25 @@ netCDFDataset::CreateLL( const char *pszFilename,
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
{
|
||||
// Works around bug of msys2 netCDF 4.9.0 package where nc_create() crashes
|
||||
VSIStatBuf sStat;
|
||||
const char* pszDir = CPLGetDirname(osFilenameForNCCreate.c_str());
|
||||
if( VSIStat(pszDir, &sStat) != 0 )
|
||||
{
|
||||
CPLError(CE_Failure, CPLE_OpenFailed,
|
||||
"Unable to create netCDF file %s: non existing output directory",
|
||||
pszFilename);
|
||||
CPLReleaseMutex(hNCMutex); // Release mutex otherwise we'll deadlock
|
||||
// with GDALDataset own mutex.
|
||||
delete poDS;
|
||||
CPLAcquireMutex(hNCMutex, 1000.0);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int status = nc_create(osFilenameForNCCreate, poDS->nCreateMode, &(poDS->cdfid));
|
||||
|
||||
// Put into define mode.
|
||||
|
|
Loading…
Reference in New Issue