diff options
author | Fate <fate-tmw@googlemail.com> | 2008-12-10 14:26:53 -0700 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-12-14 20:26:22 +0100 |
commit | db7444ffba059e5ab92c12574dca3889e6b2f2c2 (patch) | |
tree | dd1179d963386580be909e93b25b1ec68572181b /src | |
parent | 7a368588910a3eba156e1d3af60f013a5315723b (diff) | |
download | mana-db7444ffba059e5ab92c12574dca3889e6b2f2c2.tar.gz mana-db7444ffba059e5ab92c12574dca3889e6b2f2c2.tar.bz2 mana-db7444ffba059e5ab92c12574dca3889e6b2f2c2.tar.xz mana-db7444ffba059e5ab92c12574dca3889e6b2f2c2.zip |
Obscure precise home directory name when making screenshots
(cherry picked from commit 7d5c6124e9c9cf447286eaa58afe17adf6c1a81d)
Diffstat (limited to 'src')
-rw-r--r-- | src/game.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index 2e0a3cb5..2cc68c0e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -349,6 +349,7 @@ bool saveScreenshot(SDL_Surface *screenshot) static unsigned int screenshotCount = 0; // Search for an unused screenshot name + std::stringstream filenameSuffix; std::stringstream filename; std::fstream testExists; bool found = false; @@ -356,12 +357,16 @@ bool saveScreenshot(SDL_Surface *screenshot) do { screenshotCount++; filename.str(""); + filenameSuffix.str(""); + filename << PHYSFS_getUserDir(); #if (defined __USE_UNIX98 || defined __FreeBSD__) - filename << PHYSFS_getUserDir() << ".tmw/"; + filenameSuffix << ".tmw/"; #elif defined __APPLE__ - filename << PHYSFS_getUserDir() << "Desktop/"; + filenameSuffix << "Desktop/"; #endif - filename << "TMW_Screenshot_" << screenshotCount << ".png"; + filenameSuffix << "TMW_Screenshot_" << screenshotCount << ".png"; + filename << filenameSuffix.str(); + std::cerr << "Trying `" << filename.str() << "' from `" << filenameSuffix.str() << "'\n"; testExists.open(filename.str().c_str(), std::ios::in); found = !testExists.is_open(); testExists.close(); @@ -370,7 +375,7 @@ bool saveScreenshot(SDL_Surface *screenshot) if (ImageWriter::writePNG(screenshot, filename.str())) { std::stringstream chatlogentry; - chatlogentry << "Screenshot saved to " << filename.str().c_str(); + chatlogentry << "Screenshot saved to ~/" << filenameSuffix.str().c_str(); chatWindow->chatLog(chatlogentry.str(), BY_SERVER); return true; } |