Ensure that wxFileName::GetTempDir() doesn't return trailing slashes.
Sanitize the value returned by GetTempDir() to ensure that it doesn't have any trailing path separators. This happened at least under OS X where standard TMPDIR has a trailing slash and was inconsistent with the behaviour under the other platforms. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7c2257892c
commit
02f35bffeb
@ -1194,6 +1194,21 @@ wxString wxFileName::GetTempDir()
|
|||||||
dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
|
dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
|
||||||
#endif // systems with native way
|
#endif // systems with native way
|
||||||
}
|
}
|
||||||
|
else // we got directory from an environment variable
|
||||||
|
{
|
||||||
|
// remove any trailing path separators, we don't want to ever return
|
||||||
|
// them from this function for consistency
|
||||||
|
const size_t lastNonSep = dir.find_last_not_of(GetPathSeparators());
|
||||||
|
if ( lastNonSep == wxString::npos )
|
||||||
|
{
|
||||||
|
// the string consists entirely of separators, leave only one
|
||||||
|
dir = GetPathSeparator();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir.erase(lastNonSep + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fall back to hard coded value
|
// fall back to hard coded value
|
||||||
if ( dir.empty() )
|
if ( dir.empty() )
|
||||||
|
Loading…
Reference in New Issue
Block a user