+ fixes #0001238: Preferences: set temp files directory

This commit is contained in:
wmayer
2015-09-19 16:07:33 +02:00
parent 718b766737
commit ef203bc260
10 changed files with 44 additions and 10 deletions

View File

@@ -505,6 +505,16 @@ const char* Application::getExecutableName(void) const
return _mConfig["ExeName"].c_str();
}
std::string Application::getTempPath()
{
return mConfig["AppTempPath"];
}
std::string Application::getTempFileName(const char* FileName)
{
return Base::FileInfo::getTempFileName(FileName, getTempPath().c_str());
}
std::string Application::getUserAppDataDir()
{
return mConfig["UserAppData"];
@@ -1193,6 +1203,15 @@ void Application::initConfig(int argc, char ** argv)
LoadParameters();
// Set application tmp. directory
mConfig["AppTempPath"] = Base::FileInfo::getTempPath();
std::string tmpPath = _pcUserParamMngr->GetGroup("BaseApp/Preferences/General")->GetASCII("TempPath");
Base::FileInfo di(tmpPath);
if (di.exists() && di.isDir()) {
mConfig["AppTempPath"] = tmpPath + "/";
}
// capture python variables
SaveEnv("PYTHONPATH");
SaveEnv("PYTHONHOME");

View File

@@ -223,11 +223,20 @@ public:
static char** GetARGV(void){return _argv;}
//@}
/** @name Application directories */
//@{
const char* getHomePath(void) const;
const char* getExecutableName(void) const;
/*!
Returns the temporary directory. By default, this is set to the
system's temporary directory but can be customized by the user.
*/
static std::string getTempPath();
static std::string getTempFileName(const char* FileName=0);
static std::string getUserAppDataDir();
static std::string getResourceDir();
static std::string getHelpDir();
//@}
friend class App::Document;

View File

@@ -731,7 +731,7 @@ std::string Document::getTransientDirectoryName(const std::string& uuid, const s
std::stringstream s;
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(filename.c_str(), filename.size());
s << Base::FileInfo::getTempPath() << GetApplication().getExecutableName()
s << App::Application::getTempPath() << GetApplication().getExecutableName()
<< "_Doc_" << uuid
<< "_" << hash.result().toHex().left(6).constData()
<< "_" << QCoreApplication::applicationPid();