diff --git a/src/App/Application.cpp b/src/App/Application.cpp index c42d186de0..a0cd6a77cf 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1060,6 +1060,11 @@ std::string Application::getTempFileName(const char* FileName) return Base::FileInfo::getTempFileName(FileName, getTempPath().c_str()); } +std::string Application::getUserConfigDir() +{ + return mConfig["UserConfigPath"]; +} + std::string Application::getUserAppDataDir() { return mConfig["UserAppData"]; @@ -2724,9 +2729,9 @@ void Application::LoadParameters(void) // Init parameter sets =========================================================== // if (mConfig.find("UserParameter") == mConfig.end()) - mConfig["UserParameter"] = mConfig["UserAppData"] + "user.cfg"; + mConfig["UserParameter"] = mConfig["UserConfigPath"] + "user.cfg"; if (mConfig.find("SystemParameter") == mConfig.end()) - mConfig["SystemParameter"] = mConfig["UserAppData"] + "system.cfg"; + mConfig["SystemParameter"] = mConfig["UserConfigPath"] + "system.cfg"; // create standard parameter sets _pcSysParamMngr = new ParameterManager(); @@ -3096,6 +3101,11 @@ void Application::ExtractUserPath() mConfig["UserAppData"] = pathToString(appData) + PATHSEP; + // User config path (for now equal to UserAppData but will be changed to be XDG compliant) + // + mConfig["UserConfigPath"] = mConfig["UserAppData"]; + + // Set application tmp. directory // boost::filesystem::path cache = findCachePath(mConfig, cacheHome, userTemp); diff --git a/src/App/Application.h b/src/App/Application.h index 54872ecec7..265ea8a746 100644 --- a/src/App/Application.h +++ b/src/App/Application.h @@ -403,6 +403,7 @@ public: */ static std::string getTempPath(); static std::string getTempFileName(const char* FileName=0); + static std::string getUserConfigDir(); static std::string getUserAppDataDir(); static std::string getUserMacroDir(); static std::string getResourceDir(); @@ -513,6 +514,7 @@ private: static PyObject* sChangeExportModule(PyObject *self,PyObject *args); static PyObject* sGetExportType (PyObject *self,PyObject *args); static PyObject* sGetResourceDir (PyObject *self,PyObject *args); + static PyObject* sGetUserConfigDir (PyObject *self,PyObject *args); static PyObject* sGetUserAppDataDir (PyObject *self,PyObject *args); static PyObject* sGetUserMacroDir (PyObject *self,PyObject *args); static PyObject* sGetHelpDir (PyObject *self,PyObject *args); diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index de213ff32e..18fcbc88e9 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -88,8 +88,10 @@ PyMethodDef Application::Methods[] = { "Get the name of the module that can export the filetype"}, {"getResourceDir", (PyCFunction) Application::sGetResourceDir, METH_VARARGS, "Get the root directory of all resources"}, + {"getUserConfigDir", (PyCFunction) Application::sGetUserConfigDir, METH_VARARGS, + "Get the root directory of user config files"}, {"getUserAppDataDir", (PyCFunction) Application::sGetUserAppDataDir, METH_VARARGS, - "Get the root directory of user settings"}, + "Get the root directory of application data"}, {"getUserMacroDir", (PyCFunction) Application::sGetUserMacroDir, METH_VARARGS, "getUserMacroDir(bool=False) -> string" "Get the directory of the user's macro directory\n" @@ -651,6 +653,15 @@ PyObject* Application::sGetResourceDir(PyObject * /*self*/, PyObject *args) return Py::new_reference_to(datadir); } +PyObject* Application::sGetUserConfigDir(PyObject * /*self*/, PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + Py::String datadir(Application::getUserConfigDir(),"utf-8"); + return Py::new_reference_to(datadir); +} + PyObject* Application::sGetUserAppDataDir(PyObject * /*self*/, PyObject *args) { if (!PyArg_ParseTuple(args, "")) // convert args: Python->C