diff options
author | Mattes D <github@xoft.cz> | 2015-04-06 22:00:54 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-04-06 22:00:54 +0200 |
commit | 6952f2295a4ba95f75fe10f2ed8c23ed304dd59a (patch) | |
tree | 60a5e5dc389fc8cc23c89ce1eb6103297207429d /src/OSSupport/File.cpp | |
parent | Fixed crash on exit introduced with Windows Service capability. (diff) | |
download | cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar.gz cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar.bz2 cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar.lz cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar.xz cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.tar.zst cuberite-6952f2295a4ba95f75fe10f2ed8c23ed304dd59a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/OSSupport/File.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp index 8957dfaef..7ad1b3f81 100644 --- a/src/OSSupport/File.cpp +++ b/src/OSSupport/File.cpp @@ -453,6 +453,29 @@ AString cFile::ReadWholeFile(const AString & a_FileName) +AString cFile::ChangeFileExt(const AString & a_FileName, const AString & a_NewExt) +{ + auto res = a_FileName; + auto DotPos = res.rfind('.'); + if (DotPos == AString::npos) + { + // No extension, just append it: + res.push_back('.'); + res.append(a_NewExt); + } + else + { + // Replace existing extension: + res.erase(DotPos + 1, AString::npos); + res.append(a_NewExt); + } + return res; +} + + + + + int cFile::Printf(const char * a_Fmt, ...) { AString buf; |