Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from OSGeo:master #160

Merged
merged 37 commits into from
Jan 17, 2025
Merged
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4457700
Add CPLFormFilenameSafe() and CPLFormFilenameCISafe()
rouault Jan 11, 2025
32df413
port/: use CPLFormFilenameSafe() wherever possible
rouault Jan 11, 2025
0cc942a
gcore/: use CPLFormFilenameSafe()
rouault Jan 11, 2025
543e974
Add CPLGetPathSafe(), CPLGetDirnameSafe(), CPLGetBasenameSafe(), CPLG…
rouault Jan 11, 2025
34d6cc1
port/: use CPLGetPathSafe(), CPLGetDirnameSafe(), CPLGetBasenameSafe(…
rouault Jan 11, 2025
b2985b2
cpl_vsi_mem.cpp: more uses of std::string instead of CPLString; sligh…
rouault Jan 11, 2025
3c7d8eb
GDALOpenInfo: add a osExtension member
rouault Jan 11, 2025
ba7d924
Add GDALOpenInfo::IsExtensionEqualToCI()
rouault Jan 11, 2025
7ae8663
frmts/, ogr/: replace 'EQUAL(CPLGetExtension(poOpenInfo->pszFilename)…
rouault Jan 11, 2025
1a6fa67
frmts/ ogr/: replace EQUAL(CPLGetExtension(...), ...) by EQUAL(CPLGet…
rouault Jan 11, 2025
0221c26
frmts/: manual replacement of last uses of CPLGetExtension() by CPLGe…
rouault Jan 11, 2025
e8ef18c
Add CPLResetExtensionSafe(), CPLProjectRelativeFilenameSafe(), CPLCle…
rouault Jan 12, 2025
0d80c3f
MBTiles: use of RFC105 safer path functions, to avoid issue with late…
rouault Jan 12, 2025
26cea5b
Automated use of RFC105 safe functions
rouault Jan 12, 2025
5e19395
Automated use of RFC105 safe functions
rouault Jan 12, 2025
94ca285
frmts/ ogr/ .cpp: replace all remaining uses of CPLGetBasename() with…
rouault Jan 13, 2025
cd20e27
frmts/ ogr/ .cpp: replace all remaining uses of CPLGetDirname() with …
rouault Jan 13, 2025
a498111
frmts/ ogr/ .cpp: replace all remaining uses of CPLGetPath() with CPL…
rouault Jan 13, 2025
2c17139
OpenFileGDB: remove obsole #ifdef FOR_FUSIL code paths
rouault Jan 13, 2025
71c919e
frmts/ ogr/ .cpp: replace all remaining uses of CPLGetExtension() wit…
rouault Jan 13, 2025
ac575e2
Automated use of RFC105 safe functions
rouault Jan 14, 2025
c95797a
Automated use of RFC105 safe functions
rouault Jan 14, 2025
bab3feb
frmts/ ogr/ .cpp: replace all remaining uses of CPLFormCIFilename() w…
rouault Jan 14, 2025
0ba23a9
frmts/ ogr/ .cpp: replace all remaining uses of CPLResetExtension() w…
rouault Jan 14, 2025
ef2b258
frmts/ ogr/ .cpp: replace all remaining uses of CPLProjectRelativeFil…
rouault Jan 14, 2025
70d8e75
frmts/ ogr/ .cpp: replace all remaining uses of CPLGenerateTempFilena…
rouault Jan 14, 2025
d795299
frmts/ ogr/ .cpp: replace all remaining uses of CPLFormFilename() wit…
rouault Jan 14, 2025
8125286
gnm: convert to safe path functions
rouault Jan 14, 2025
1acb5ca
port: convert to safe path functions
rouault Jan 14, 2025
f9e3c25
gcore: convert to safe path functions
rouault Jan 14, 2025
cc71e66
ogr: replace CPLExpandTilde() with CPLExpandTildeSafe()
rouault Jan 14, 2025
7b636ab
apps: convert to safe path functions
rouault Jan 14, 2025
887535a
Remove last remaining uses of 'unsafe' path functions from C++ code
rouault Jan 14, 2025
df669f9
Prevent using 'unsafe' path functions from GDAL C++ code
rouault Jan 14, 2025
99dc672
VSIArchiveFilesystemHandler::SplitFilename(): revet no longer need ha…
rouault Jan 15, 2025
48b704b
Merge pull request #11639 from rouault/CPLFormFilenameSafe
rouault Jan 17, 2025
3da6544
CI gdal-master conda: fix upload of packages
rouault Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Automated use of RFC105 safe functions
Done with following script:
```bash
funcs=(CPLGetPath CPLGetDirname CPLGetBasename CPLGetExtension CPLFormFilename CPLFormCIFilename CPLResetExtension CPLProjectRelativeFilename CPLCleanTrailingSlash CPLGenerateTempFilename CPLExpandTilde CPLLaunderForFilename)

for func in "${funcs[@]}"; do
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/const char \*([a-zA-Z_][a-zA-Z0-9_]*)\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\);/const char *\1 = ${func}(\2);/g" {} \;
done

for func in "${funcs[@]}"; do
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/CPLString\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\)/CPLString(${func}Safe(\1))/g" {} \;
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/std::string\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\)/std::string(${func}Safe(\1))/g" {} \;
done

for func in "${funcs[@]}"; do
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\((.*)\)/\1${func}Safe(\2)/g" {} \;
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\((.*)\)/\1${func}Safe(\2)/g" {} \;
done

for func in "${funcs[@]}"; do
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\(([^)]+)\)/\1${func}Safe(\2)/g" {} \;
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\(([^)]+)\)/\1${func}Safe(\2)/g" {} \;
done

for func in "${funcs[@]}"; do
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)/(${func}Safe(\1).c_str()/g" {} \;
  find frmts ogr -name "*.cpp" -exec sed -i -E "s/, ${func}\(([^()]*(\([^()]*\))?[^()]*)\)/, ${func}Safe(\1).c_str()/g" {} \;
done
```
rouault committed Jan 13, 2025
commit 26cea5b25f91de294303d4cceb1c7c2250b5aad3
13 changes: 7 additions & 6 deletions frmts/aaigrid/aaigriddataset.cpp
Original file line number Diff line number Diff line change
@@ -1218,9 +1218,10 @@ GDALDataset *AAIGDataset::CommonOpen(GDALOpenInfo *poOpenInfo,
}

// Try to read projection file.
char *const pszDirname = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));
char *const pszDirname =
CPLStrdup(CPLGetPathSafe(poOpenInfo->pszFilename).c_str());
char *const pszBasename =
CPLStrdup(CPLGetBasename(poOpenInfo->pszFilename));
CPLStrdup(CPLGetBasenameSafe(poOpenInfo->pszFilename).c_str());

poDS->osPrjFilename = CPLFormFilename(pszDirname, pszBasename, "prj");
int nRet = 0;
@@ -1557,10 +1558,10 @@ GDALDataset *AAIGDataset::CreateCopy(const char *pszFilename,
const char *pszOriginalProjection = poSrcDS->GetProjectionRef();
if (!EQUAL(pszOriginalProjection, ""))
{
char *pszDirname = CPLStrdup(CPLGetPath(pszFilename));
char *pszBasename = CPLStrdup(CPLGetBasename(pszFilename));
char *pszPrjFilename =
CPLStrdup(CPLFormFilename(pszDirname, pszBasename, "prj"));
char *pszDirname = CPLStrdup(CPLGetPathSafe(pszFilename).c_str());
char *pszBasename = CPLStrdup(CPLGetBasenameSafe(pszFilename).c_str());
char *pszPrjFilename = CPLStrdup(
CPLFormFilenameSafe(pszDirname, pszBasename, "prj").c_str());
VSILFILE *fp = VSIFOpenL(pszPrjFilename, "wt");
if (fp != nullptr)
{
8 changes: 4 additions & 4 deletions frmts/adrg/adrgdataset.cpp
Original file line number Diff line number Diff line change
@@ -1337,7 +1337,7 @@ char **ADRGDataset::GetGENListFromTHF(const char *pszFileName)
{
CPLDebug("ADRG", "Found GEN file in THF : %s",
osSubFileName.c_str());
CPLString osGENFileName(CPLGetDirname(pszFileName));
CPLString osGENFileName(CPLGetDirnameSafe(pszFileName));
char **tokens =
CSLTokenizeString2(osSubFileName.c_str(), "/\"", 0);
char **ptr = tokens;
@@ -1472,7 +1472,7 @@ char **ADRGDataset::GetIMGListFromGEN(const char *pszFileName,
CPLDebug("ADRG", "BAD=%s", osBAD.c_str());

/* Build full IMG file name from BAD value */
CPLString osGENDir(CPLGetDirname(pszFileName));
CPLString osGENDir(CPLGetDirnameSafe(pszFileName));

const CPLString osFileName =
CPLFormFilename(osGENDir.c_str(), osBAD.c_str(), nullptr);
@@ -1704,7 +1704,7 @@ GDALDataset *ADRGDataset::Create(const char *pszFilename, int nXSize,
return nullptr;
}

CPLString osBaseFileName(CPLGetBasename(pszFilename));
CPLString osBaseFileName(CPLGetBasenameSafe(pszFilename));
if (osBaseFileName.size() != 8 || osBaseFileName[6] != DIGIT_ZERO ||
osBaseFileName[7] != '1')
{
@@ -1733,7 +1733,7 @@ GDALDataset *ADRGDataset::Create(const char *pszFilename, int nXSize,
return nullptr;
}

CPLString osDirname(CPLGetDirname(pszFilename));
CPLString osDirname(CPLGetDirnameSafe(pszFilename));
CPLString osTransh01THF(
CPLFormFilename(osDirname.c_str(), "TRANSH01.THF", nullptr));
VSILFILE *fdTHF = VSIFOpenL(osTransh01THF.c_str(), "wb");
7 changes: 4 additions & 3 deletions frmts/adrg/srpdataset.cpp
Original file line number Diff line number Diff line change
@@ -1058,7 +1058,7 @@ char **SRPDataset::GetGENListFromTHF(const char *pszFileName)
if (!module.Open(pszFileName, TRUE))
return papszFileNames;

CPLString osDirName(CPLGetDirname(pszFileName));
CPLString osDirName(CPLGetDirnameSafe(pszFileName));

while (true)
{
@@ -1163,7 +1163,8 @@ char **SRPDataset::GetGENListFromTHF(const char *pszFileName)
{
if (EQUAL(CPLGetExtensionSafe(*ptrDir).c_str(),
"GEN") &&
EQUALN(CPLGetBasename(*ptrDir), osName, 6))
EQUALN(CPLGetBasenameSafe(*ptrDir).c_str(),
osName, 6))
{
bFound = 1;
osGENFileName = CPLFormFilename(
@@ -1401,7 +1402,7 @@ char **SRPDataset::GetIMGListFromGEN(const char *pszFileName,
CPLDebug("SRP", "BAD=%s", osBAD.c_str());

/* Build full IMG file name from BAD value */
const CPLString osGENDir(CPLGetDirname(pszFileName));
const CPLString osGENDir(CPLGetDirnameSafe(pszFileName));

const CPLString osFileName =
CPLFormFilename(osGENDir.c_str(), osBAD.c_str(), nullptr);
5 changes: 3 additions & 2 deletions frmts/ceos2/sar_ceosdataset.cpp
Original file line number Diff line number Diff line change
@@ -1822,8 +1822,9 @@ GDALDataset *SAR_CEOSDataset::Open(GDALOpenInfo *poOpenInfo)
/* -------------------------------------------------------------------- */
/* Try the various filenames. */
/* -------------------------------------------------------------------- */
char *pszPath = CPLStrdup(CPLGetPath(poOpenInfo->pszFilename));
char *pszBasename = CPLStrdup(CPLGetBasename(poOpenInfo->pszFilename));
char *pszPath = CPLStrdup(CPLGetPathSafe(poOpenInfo->pszFilename).c_str());
char *pszBasename =
CPLStrdup(CPLGetBasenameSafe(poOpenInfo->pszFilename).c_str());
char *pszExtension =
CPLStrdup(CPLGetExtensionSafe(poOpenInfo->pszFilename).c_str());

5 changes: 3 additions & 2 deletions frmts/coasp/coasp_dataset.cpp
Original file line number Diff line number Diff line change
@@ -393,8 +393,9 @@ GDALDataset *COASPDataset::Open(GDALOpenInfo *poOpenInfo)
poDS->pszFileName = VSIStrdup(poOpenInfo->pszFilename);

/* determine the file name prefix */
char *pszBaseName = VSIStrdup(CPLGetBasename(poDS->pszFileName));
char *pszDir = VSIStrdup(CPLGetPath(poDS->pszFileName));
char *pszBaseName =
VSIStrdup(CPLGetBasenameSafe(poDS->pszFileName).c_str());
char *pszDir = VSIStrdup(CPLGetPathSafe(poDS->pszFileName).c_str());
const char *pszExt = "rc";
int nNull = static_cast<int>(strlen(pszBaseName)) - 1;
if (nNull <= 0)
3 changes: 2 additions & 1 deletion frmts/esric/esric_dataset.cpp
Original file line number Diff line number Diff line change
@@ -684,7 +684,8 @@ GDALDataset *ECDataset::Open(GDALOpenInfo *poOpenInfo,
tileBundlesPath.erase(0, 2);
}

ds->dname.Printf("%s/%s", CPLGetDirname(poOpenInfo->pszFilename),
ds->dname.Printf("%s/%s",
CPLGetDirnameSafe(poOpenInfo->pszFilename).c_str(),
tileBundlesPath.c_str());
CPLErr error = ds->InitializeFromJSON(oRoot);
if (CE_None != error)
9 changes: 5 additions & 4 deletions frmts/gti/gdaltileindexdataset.cpp
Original file line number Diff line number Diff line change
@@ -591,15 +591,16 @@ static std::string GetAbsoluteFileName(const char *pszTileName,
const std::string osRet =
CPLIsFilenameRelative(osPath.c_str())
? oSubDSInfo->ModifyPathComponent(
CPLProjectRelativeFilename(CPLGetPath(pszVRTName),
osPath.c_str()))
CPLProjectRelativeFilename(
CPLGetPathSafe(pszVRTName).c_str(),
osPath.c_str()))
: std::string(pszTileName);
GDALDestroySubdatasetInfo(oSubDSInfo);
return osRet;
}

const std::string osRelativeMadeAbsolute =
CPLProjectRelativeFilename(CPLGetPath(pszVRTName), pszTileName);
const std::string osRelativeMadeAbsolute = CPLProjectRelativeFilename(
CPLGetPathSafe(pszVRTName).c_str(), pszTileName);
VSIStatBufL sStat;
if (VSIStatL(osRelativeMadeAbsolute.c_str(), &sStat) == 0)
return osRelativeMadeAbsolute;
3 changes: 2 additions & 1 deletion frmts/gtiff/cogdriver.cpp
Original file line number Diff line number Diff line change
@@ -62,7 +62,8 @@ static CPLString GetTmpFilename(const char *pszFilename, const char *pszExt)
if (!bSupportsRandomWrite ||
CPLGetConfigOption("CPL_TMPDIR", nullptr) != nullptr)
{
osTmpFilename = CPLGenerateTempFilename(CPLGetBasename(pszFilename));
osTmpFilename =
CPLGenerateTempFilename(CPLGetBasenameSafe(pszFilename).c_str());
}
else
osTmpFilename = pszFilename;
2 changes: 1 addition & 1 deletion frmts/gtiff/gtiffdataset_read.cpp
Original file line number Diff line number Diff line change
@@ -5771,7 +5771,7 @@ CSLConstList GTiffDataset::GetSiblingFiles()
const int nMaxFiles =
atoi(CPLGetConfigOption("GDAL_READDIR_LIMIT_ON_OPEN", "1000"));
CPLStringList aosSiblingFiles(
VSIReadDirEx(CPLGetDirname(m_pszFilename), nMaxFiles));
VSIReadDirEx(CPLGetDirnameSafe(m_pszFilename).c_str(), nMaxFiles));
if (nMaxFiles > 0 && aosSiblingFiles.size() > nMaxFiles)
{
CPLDebug("GTiff", "GDAL_READDIR_LIMIT_ON_OPEN reached on %s",
2 changes: 1 addition & 1 deletion frmts/gtiff/gtiffdataset_write.cpp
Original file line number Diff line number Diff line change
@@ -5515,7 +5515,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize,
CPLTestBool(CPLGetConfigOption("CHECK_DISK_FREE_SPACE", "TRUE")))
{
GIntBig nFreeDiskSpace =
VSIGetDiskFreeSpace(CPLGetDirname(pszFilename));
VSIGetDiskFreeSpace(CPLGetDirnameSafe(pszFilename).c_str());
if (nFreeDiskSpace >= 0 && nFreeDiskSpace < dfUncompressedImageSize)
{
ReportError(pszFilename, CE_Failure, CPLE_FileIO,
2 changes: 1 addition & 1 deletion frmts/hdf4/hdf4imagedataset.cpp
Original file line number Diff line number Diff line change
@@ -288,7 +288,7 @@ CPLErr HDF4ImageRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff,
/* to look in to find the external files. Normally this is the */
/* directory holding the hdf file. */
/* -------------------------------------------------------------------- */
HXsetdir(CPLGetPath(poGDS->pszFilename));
HXsetdir(CPLGetPathSafe(poGDS->pszFilename).c_str());

/* -------------------------------------------------------------------- */
/* Handle different configurations. */
11 changes: 6 additions & 5 deletions frmts/hdf5/s100.cpp
Original file line number Diff line number Diff line change
@@ -417,8 +417,9 @@ std::string S100ReadMetadata(GDALDataset *poDS, const std::string &osFilename,
const char *pszVal = poAttr->ReadAsString();
if (pszVal && pszVal[0])
{
osMetadataFile = CPLFormFilename(CPLGetPath(osFilename.c_str()),
pszVal, nullptr);
osMetadataFile =
CPLFormFilename(CPLGetPathSafe(osFilename.c_str()).c_str(),
pszVal, nullptr);
VSIStatBufL sStat;
if (VSIStatL(osMetadataFile.c_str(), &sStat) != 0)
{
@@ -427,9 +428,9 @@ std::string S100ReadMetadata(GDALDataset *poDS, const std::string &osFilename,
// but the actual filename does not start with "MD_"...
if (STARTS_WITH(pszVal, "MD_"))
{
osMetadataFile =
CPLFormFilename(CPLGetPath(osFilename.c_str()),
pszVal + strlen("MD_"), nullptr);
osMetadataFile = CPLFormFilename(
CPLGetPathSafe(osFilename.c_str()).c_str(),
pszVal + strlen("MD_"), nullptr);
if (VSIStatL(osMetadataFile.c_str(), &sStat) != 0)
{
osMetadataFile.clear();
6 changes: 3 additions & 3 deletions frmts/hfa/hfaband.cpp
Original file line number Diff line number Diff line change
@@ -174,10 +174,10 @@ CPLErr HFABand::LoadOverviews()
if (psHFA == nullptr)
{
char *pszBasename =
CPLStrdup(CPLGetBasename(psInfo->pszFilename));
CPLStrdup(CPLGetBasenameSafe(psInfo->pszFilename).c_str());

pszJustFilename =
CPLStrdup(CPLFormFilename(nullptr, pszBasename, "rrd"));
pszJustFilename = CPLStrdup(
CPLFormFilenameSafe(nullptr, pszBasename, "rrd").c_str());
CPLDebug("HFA",
"Failed to find overview file with "
"expected name, try %s instead.",
20 changes: 10 additions & 10 deletions frmts/hfa/hfaopen.cpp
Original file line number Diff line number Diff line change
@@ -201,7 +201,7 @@ HFAHandle HFAOpen(const char *pszFilename, const char *pszAccess)
static_cast<HFAInfo_t *>(CPLCalloc(sizeof(HFAInfo_t), 1));

psInfo->pszFilename = CPLStrdup(CPLGetFilename(pszFilename));
psInfo->pszPath = CPLStrdup(CPLGetPath(pszFilename));
psInfo->pszPath = CPLStrdup(CPLGetPathSafe(pszFilename).c_str());
psInfo->fp = fp;
if (EQUAL(pszAccess, "r") || EQUAL(pszAccess, "rb"))
psInfo->eAccess = HFA_ReadOnly;
@@ -340,8 +340,8 @@ HFAInfo_t *HFAGetDependent(HFAInfo_t *psBase, const char *pszFilename)
// Try to open the dependent file.
const char *pszMode = psBase->eAccess == HFA_Update ? "r+b" : "rb";

char *pszDependent =
CPLStrdup(CPLFormFilename(psBase->pszPath, pszFilename, nullptr));
char *pszDependent = CPLStrdup(
CPLFormFilenameSafe(psBase->pszPath, pszFilename, nullptr).c_str());

VSILFILE *fp = VSIFOpenL(pszDependent, pszMode);
if (fp != nullptr)
@@ -1808,7 +1808,7 @@ HFAHandle HFACreateLL(const char *pszFilename)
psInfo->pProParameters = nullptr;
psInfo->bTreeDirty = false;
psInfo->pszFilename = CPLStrdup(CPLGetFilename(pszFilename));
psInfo->pszPath = CPLStrdup(CPLGetPath(pszFilename));
psInfo->pszPath = CPLStrdup(CPLGetPathSafe(pszFilename).c_str());

// Write out the Ehfa_HeaderTag.
bool bRet = VSIFWriteL((void *)"EHFA_HEADER_TAG", 1, 16, fp) > 0;
@@ -2957,14 +2957,14 @@ bool HFACreateSpillStack(HFAInfo_t *psInfo, int nXSize, int nYSize, int nLayers,
{
const auto osExt = CPLGetExtensionSafe(psInfo->pszFilename);
if (EQUAL(osExt.c_str(), "rrd"))
psInfo->pszIGEFilename =
CPLStrdup(CPLResetExtension(psInfo->pszFilename, "rde"));
psInfo->pszIGEFilename = CPLStrdup(
CPLResetExtensionSafe(psInfo->pszFilename, "rde").c_str());
else if (EQUAL(osExt.c_str(), "aux"))
psInfo->pszIGEFilename =
CPLStrdup(CPLResetExtension(psInfo->pszFilename, "axe"));
psInfo->pszIGEFilename = CPLStrdup(
CPLResetExtensionSafe(psInfo->pszFilename, "axe").c_str());
else
psInfo->pszIGEFilename =
CPLStrdup(CPLResetExtension(psInfo->pszFilename, "ige"));
psInfo->pszIGEFilename = CPLStrdup(
CPLResetExtensionSafe(psInfo->pszFilename, "ige").c_str());
}

char *pszFullFilename = CPLStrdup(
3 changes: 2 additions & 1 deletion frmts/http/httpdriver.cpp
Original file line number Diff line number Diff line change
@@ -174,7 +174,8 @@ static GDALDataset *HTTPOpen(GDALOpenInfo *poOpenInfo)
CPLString osTempFilename;

#ifdef _WIN32
const char *pszPath = CPLGetPath(CPLGenerateTempFilename(NULL));
const char *pszPath =
CPLGetPath(CPLGenerateTempFilenameSafe(NULL).c_str());
#else
const char *pszPath = "/tmp";
#endif
9 changes: 5 additions & 4 deletions frmts/idrisi/IdrisiDataset.cpp
Original file line number Diff line number Diff line change
@@ -2393,8 +2393,9 @@ CPLErr IdrisiGeoReference2Wkt(const char *pszFilename, const char *pszRefSystem,
// Search for georeference file <RefSystem>.ref
// ------------------------------------------------------------------

const char *pszFName = CPLSPrintf("%s%c%s.ref", CPLGetDirname(pszFilename),
PATHDELIM, pszRefSystem);
const char *pszFName =
CPLSPrintf("%s%c%s.ref", CPLGetDirnameSafe(pszFilename).c_str(),
PATHDELIM, pszRefSystem);

if (!FileExists(pszFName))
{
@@ -3129,10 +3130,10 @@ CPLErr IdrisiDataset::Wkt2GeoReference(const OGRSpatialReference &oSRS,
papszRef =
CSLAddNameValue(papszRef, refSTANDL_2, CPLSPrintf("%.9g", dfStdP2));
myCSLSetNameValueSeparator(papszRef, ": ");
SaveAsCRLF(papszRef, CPLResetExtension(pszFilename, extREF));
SaveAsCRLF(papszRef, CPLResetExtensionSafe(pszFilename, extREF).c_str());
CSLDestroy(papszRef);

*pszRefSystem = CPLStrdup(CPLGetBasename(pszFilename));
*pszRefSystem = CPLStrdup(CPLGetBasenameSafe(pszFilename).c_str());
*pszRefUnit = CPLStrdup(pszLinearUnit);

CPLFree(pszGeorefName);
4 changes: 2 additions & 2 deletions frmts/ilwis/ilwiscoordinatesystem.cpp
Original file line number Diff line number Diff line change
@@ -996,8 +996,8 @@ CPLErr ILWISDataset::WriteProjection()
OGRSpatialReference *poGeogSRS = nullptr;

std::string csFileName = CPLResetExtension(osFileName, "csy");
std::string pszBaseName = std::string(CPLGetBasename(osFileName));
// std::string pszPath = std::string(CPLGetPath( osFileName ));
std::string pszBaseName = std::string(CPLGetBasenameSafe(osFileName));
// std::string pszPath = std::string(CPLGetPathSafe( osFileName ));
const bool bHaveSRS = !m_oSRS.IsEmpty();

const IlwisDatums *piwDatum = iwDatums;
Loading