diff options
author | Bernd Wachter <bwachter-tmw@lart.info> | 2010-03-01 01:06:17 +0100 |
---|---|---|
committer | Bernd Wachter <bwachter-tmw@lart.info> | 2010-03-01 01:15:17 +0100 |
commit | d357426f64cb6f484214ec166615d70e789d63c4 (patch) | |
tree | dadabcbf9174df7957640a1fa5ebfa9ade31f5b7 | |
parent | 56e9e78a8775be791bf1acf203251aa28f0fa0cb (diff) | |
download | mana-d357426f64cb6f484214ec166615d70e789d63c4.tar.gz mana-d357426f64cb6f484214ec166615d70e789d63c4.tar.bz2 mana-d357426f64cb6f484214ec166615d70e789d63c4.tar.xz mana-d357426f64cb6f484214ec166615d70e789d63c4.zip |
Check and create screenshot directory only when a screenshot is made
-rw-r--r-- | src/client.cpp | 12 | ||||
-rw-r--r-- | src/game.cpp | 12 |
2 files changed, 11 insertions, 13 deletions
diff --git a/src/client.cpp b/src/client.cpp index a21d004d..dfa42034 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1181,10 +1181,6 @@ void Client::initScreenshotDir() mScreenshotDir = getSpecialFolderLocation(CSIDL_DESKTOP); #else mScreenshotDir = std::string(PHYSFS_getUserDir()) + "Desktop"; - // If ~/Desktop does not exist, we save screenshots in the user's home. - struct stat statbuf; - if (stat(mScreenshotDir.c_str(), &statbuf)) - mScreenshotDir = std::string(PHYSFS_getUserDir()); #endif } config.setValue("screenshotDirectory", mScreenshotDir); @@ -1203,14 +1199,6 @@ void Client::initScreenshotDir() } } } - - if (mkdir_r(mScreenshotDir.c_str())) - { - logger->log("Directory %s doesn't exist and can't be created! " - "Setting screenshot directory to home.", - mScreenshotDir.c_str()); - mScreenshotDir = std::string(PHYSFS_getUserDir()); - } } void Client::accountLogin(LoginData *loginData) diff --git a/src/game.cpp b/src/game.cpp index 00c143d4..e753e1f7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -82,6 +82,7 @@ #include "resources/resourcemanager.h" #include "utils/gettext.h" +#include "utils/mkdir.h" #include <guichan/exception.hpp> #include <guichan/focushandler.hpp> @@ -297,13 +298,22 @@ static bool saveScreenshot() std::stringstream filenameSuffix; std::stringstream filename; std::fstream testExists; + std::string screenshotDirectory = Client::getScreenshotDirectory(); bool found = false; + if (mkdir_r(screenshotDirectory.c_str()) != 0) + { + logger->log("Directory %s doesn't exist and can't be created! " + "Setting screenshot directory to home.", + screenshotDirectory.c_str()); + screenshotDirectory = std::string(PHYSFS_getUserDir()); + } + do { screenshotCount++; filenameSuffix.str(""); filename.str(""); - filename << Client::getScreenshotDirectory() << "/"; + filename << screenshotDirectory << "/"; filenameSuffix << branding.getValue("appShort", "Mana") << "_Screenshot_" << screenshotCount << ".png"; filename << filenameSuffix.str(); |