From db7444ffba059e5ab92c12574dca3889e6b2f2c2 Mon Sep 17 00:00:00 2001 From: Fate Date: Wed, 10 Dec 2008 14:26:53 -0700 Subject: Obscure precise home directory name when making screenshots (cherry picked from commit 7d5c6124e9c9cf447286eaa58afe17adf6c1a81d) --- src/game.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-70-g09d2