diff options
author | Mattes D <github@xoft.cz> | 2015-04-11 17:42:32 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-11 17:42:32 +0200 |
commit | 79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc (patch) | |
tree | 721cb564484d40b6e2e61174d15a24e5e1ebbe02 /src/OSSupport/File.cpp | |
parent | Added more cFile API functions. (diff) | |
download | cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar.gz cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar.bz2 cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar.lz cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar.xz cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.tar.zst cuberite-79e8f8fb20f9c2a4aebd6178a99b40f4e7b4fccc.zip |
Diffstat (limited to '')
-rw-r--r-- | src/OSSupport/File.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index fe72f34b4..43105b230 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -481,13 +481,25 @@ AString cFile::ChangeFileExt(const AString & a_FileName, const AString & a_NewEx ) { // No extension, just append the new one: - res.push_back('.'); + if (!a_NewExt.empty() && (a_NewExt[0] != '.')) + { + // a_NewExt doesn't start with a dot, insert one: + res.push_back('.'); + } res.append(a_NewExt); } else { // Replace existing extension: - res.erase(DotPos + 1, AString::npos); + if (!a_NewExt.empty() && (a_NewExt[0] != '.')) + { + // a_NewExt doesn't start with a dot, keep the current one: + res.erase(DotPos + 1, AString::npos); + } + else + { + res.erase(DotPos, AString::npos); + } res.append(a_NewExt); } return res; |