+ fixes #0001238: Preferences: set temp files directory
This commit is contained in:
parent
e5c3a09502
commit
2991bbf033
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1841,7 +1841,7 @@ void Application::runApplication(void)
|
|||
|
||||
try {
|
||||
std::stringstream s;
|
||||
s << Base::FileInfo::getTempPath() << App::GetApplication().getExecutableName()
|
||||
s << App::Application::getTempPath() << App::GetApplication().getExecutableName()
|
||||
<< "_" << QCoreApplication::applicationPid() << ".lock";
|
||||
// open a lock file with the PID
|
||||
Base::FileInfo fi(s.str());
|
||||
|
@ -1875,7 +1875,7 @@ void Application::runApplication(void)
|
|||
|
||||
void Application::checkForPreviousCrashes()
|
||||
{
|
||||
QDir tmp = QDir::temp();
|
||||
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
|
||||
tmp.setNameFilters(QStringList() << QString::fromAscii("*.lock"));
|
||||
tmp.setFilter(QDir::Files);
|
||||
|
||||
|
|
|
@ -310,6 +310,9 @@ public:
|
|||
, writer(dir)
|
||||
{
|
||||
writer.setModes(modes);
|
||||
// always force binary format because ASCII
|
||||
// is not reentrant. See PropertyPartShape::SaveDocFile
|
||||
write.setMode("BinaryBrep");
|
||||
writer.putNextEntry(file);
|
||||
}
|
||||
virtual ~RecoveryRunnable()
|
||||
|
|
|
@ -925,7 +925,7 @@ void StdCmdDuplicateSelection::activated(int iMsg)
|
|||
if (objs.empty())
|
||||
return;
|
||||
|
||||
Base::FileInfo fi(Base::FileInfo::getTempFileName());
|
||||
Base::FileInfo fi(App::Application::getTempFileName());
|
||||
{
|
||||
std::vector<App::DocumentObject*> sel; // selected
|
||||
std::vector<App::DocumentObject*> all; // object sub-graph
|
||||
|
|
|
@ -65,7 +65,8 @@ int DlgEditFileIncludePropertyExternal::Do(void)
|
|||
QFileInfo file = QString::fromUtf8(Prop.getValue());
|
||||
assert(file.exists());
|
||||
|
||||
QString TempFile = QDir::temp().absolutePath() + QString::fromAscii("/") + file.fileName();
|
||||
QDir tmp = QString::fromUtf8(App::Application::getTempPath().c_str());
|
||||
QString TempFile = tmp.absoluteFilePath(file.fileName());
|
||||
QFile::remove(TempFile);
|
||||
|
||||
QFile::copy(file.absoluteFilePath(),TempFile);
|
||||
|
|
|
@ -1334,7 +1334,7 @@ QMimeData * MainWindow::createMimeDataFromSelection () const
|
|||
}
|
||||
else {
|
||||
mime = QLatin1String("application/x-documentobject-file");
|
||||
static Base::FileInfo fi(Base::FileInfo::getTempFileName());
|
||||
static Base::FileInfo fi(App::Application::getTempFileName());
|
||||
Base::ofstream str(fi, std::ios::out | std::ios::binary);
|
||||
// need this instance to call MergeDocuments::Save()
|
||||
App::Document* doc = sel.front()->getDocument();
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <Base/FileInfo.h>
|
||||
#include <Base/TimeInfo.h>
|
||||
#include <Base/Console.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
#include <Mod/Mesh/App/Core/MeshKernel.h>
|
||||
#include <Mod/Mesh/App/Core/Evaluation.h>
|
||||
|
@ -1125,7 +1126,7 @@ void FemMesh::Restore(Base::XMLReader &reader)
|
|||
void FemMesh::SaveDocFile (Base::Writer &writer) const
|
||||
{
|
||||
// create a temporary file and copy the content to the zip stream
|
||||
Base::FileInfo fi(Base::FileInfo::getTempFileName().c_str());
|
||||
Base::FileInfo fi(App::Application::getTempFileName().c_str());
|
||||
|
||||
myMesh->ExportUNV(fi.filePath().c_str());
|
||||
|
||||
|
@ -1154,7 +1155,7 @@ void FemMesh::SaveDocFile (Base::Writer &writer) const
|
|||
void FemMesh::RestoreDocFile(Base::Reader &reader)
|
||||
{
|
||||
// create a temporary file and copy the content from the zip stream
|
||||
Base::FileInfo fi(Base::FileInfo::getTempFileName().c_str());
|
||||
Base::FileInfo fi(App::Application::getTempFileName().c_str());
|
||||
|
||||
// read in the ASCII file and write back to the file stream
|
||||
Base::ofstream file(fi, std::ios::out | std::ios::binary);
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <Base/Exception.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include "PropertyTopoShape.h"
|
||||
|
@ -277,7 +278,7 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const
|
|||
// create a temporary file and copy the content to the zip stream
|
||||
// once the tmp. filename is known use always the same because otherwise
|
||||
// we may run into some problems on the Linux platform
|
||||
static Base::FileInfo fi(Base::FileInfo::getTempFileName());
|
||||
static Base::FileInfo fi(App::Application::getTempFileName());
|
||||
|
||||
if (!BRepTools::Write(myShape,(const Standard_CString)fi.filePath().c_str())) {
|
||||
// Note: Do NOT throw an exception here because if the tmp. file could
|
||||
|
@ -330,7 +331,7 @@ void PropertyPartShape::RestoreDocFile(Base::Reader &reader)
|
|||
BRep_Builder builder;
|
||||
|
||||
// create a temporary file and copy the content from the zip stream
|
||||
Base::FileInfo fi(Base::FileInfo::getTempFileName());
|
||||
Base::FileInfo fi(App::Application::getTempFileName());
|
||||
|
||||
// read in the ASCII file and write back to the file stream
|
||||
Base::ofstream file(fi, std::ios::out | std::ios::binary);
|
||||
|
|
Loading…
Reference in New Issue
Block a user