mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
XDG compliant paths
This commit is contained in:
parent
aef0fd1460
commit
33389b9b63
15 changed files with 119 additions and 117 deletions
|
@ -219,7 +219,7 @@ bool Launcher::MainDialog::showFirstRunDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the file if it doesn't already exist, else the importer will fail
|
// Create the file if it doesn't already exist, else the importer will fail
|
||||||
QString path = QString::fromStdString(mCfgMgr.getUserPath().string()) + QString("openmw.cfg");
|
QString path = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + QString("openmw.cfg");
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -334,7 +334,7 @@ bool Launcher::MainDialog::setupLauncherSettings()
|
||||||
{
|
{
|
||||||
mLauncherSettings.setMultiValueEnabled(true);
|
mLauncherSettings.setMultiValueEnabled(true);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
||||||
|
|
||||||
QStringList paths;
|
QStringList paths;
|
||||||
paths.append(QString("launcher.cfg"));
|
paths.append(QString("launcher.cfg"));
|
||||||
|
@ -440,7 +440,7 @@ bool Launcher::expansions(Launcher::UnshieldThread& cd)
|
||||||
|
|
||||||
bool Launcher::MainDialog::setupGameSettings()
|
bool Launcher::MainDialog::setupGameSettings()
|
||||||
{
|
{
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
||||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||||
|
|
||||||
// Load the user config file first, separately
|
// Load the user config file first, separately
|
||||||
|
@ -591,7 +591,7 @@ bool Launcher::MainDialog::setupGraphicsSettings()
|
||||||
{
|
{
|
||||||
mGraphicsSettings.setMultiValueEnabled(false);
|
mGraphicsSettings.setMultiValueEnabled(false);
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
||||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||||
|
|
||||||
QFile localDefault(QString("settings-default.cfg"));
|
QFile localDefault(QString("settings-default.cfg"));
|
||||||
|
@ -678,7 +678,7 @@ bool Launcher::MainDialog::writeSettings()
|
||||||
mGraphicsPage->saveSettings();
|
mGraphicsPage->saveSettings();
|
||||||
mDataFilesPage->saveSettings();
|
mDataFilesPage->saveSettings();
|
||||||
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserConfigPath().string());
|
||||||
QDir dir(userPath);
|
QDir dir(userPath);
|
||||||
|
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
|
|
|
@ -86,10 +86,6 @@ void CS::Editor::setupDataFiles()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the charset for reading the esm/esp files
|
|
||||||
// QString encoding = QString::fromStdString(variables["encoding"].as<std::string>());
|
|
||||||
//mFileDialog.setEncoding(encoding);
|
|
||||||
|
|
||||||
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
dataDirs.insert (dataDirs.end(), dataLocal.begin(), dataLocal.end());
|
||||||
|
|
||||||
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
|
mDocumentManager.setResourceDir (variables["resources"].as<std::string>());
|
||||||
|
|
|
@ -2221,7 +2221,7 @@ void CSMDoc::Document::createBase()
|
||||||
|
|
||||||
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_)
|
CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, const std::vector< boost::filesystem::path >& files, const boost::filesystem::path& savePath, const boost::filesystem::path& resDir, bool new_)
|
||||||
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
|
: mSavePath (savePath), mContentFiles (files), mTools (mData), mResDir(resDir),
|
||||||
mProjectPath ((configuration.getUserPath() / "projects") /
|
mProjectPath ((configuration.getUserDataPath() / "projects") /
|
||||||
(savePath.filename().string() + ".project")),
|
(savePath.filename().string() + ".project")),
|
||||||
mSaving (*this, mProjectPath)
|
mSaving (*this, mProjectPath)
|
||||||
{
|
{
|
||||||
|
@ -2254,7 +2254,7 @@ CSMDoc::Document::Document (const Files::ConfigurationManager& configuration, co
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::filesystem::path locCustomFiltersPath (configuration.getUserPath());
|
boost::filesystem::path locCustomFiltersPath (configuration.getUserDataPath());
|
||||||
locCustomFiltersPath /= "defaultfilters";
|
locCustomFiltersPath /= "defaultfilters";
|
||||||
|
|
||||||
if (boost::filesystem::exists(locCustomFiltersPath))
|
if (boost::filesystem::exists(locCustomFiltersPath))
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
CSMDoc::DocumentManager::DocumentManager (const Files::ConfigurationManager& configuration)
|
||||||
: mConfiguration (configuration)
|
: mConfiguration (configuration)
|
||||||
{
|
{
|
||||||
boost::filesystem::path projectPath = configuration.getUserPath() / "projects";
|
boost::filesystem::path projectPath = configuration.getUserDataPath() / "projects";
|
||||||
|
|
||||||
if (!boost::filesystem::is_directory (projectPath))
|
if (!boost::filesystem::is_directory (projectPath))
|
||||||
boost::filesystem::create_directories (projectPath);
|
boost::filesystem::create_directories (projectPath);
|
||||||
|
@ -53,4 +53,4 @@ bool CSMDoc::DocumentManager::removeDocument (Document *document)
|
||||||
void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& parResDir)
|
void CSMDoc::DocumentManager::setResourceDir (const boost::filesystem::path& parResDir)
|
||||||
{
|
{
|
||||||
mResDir = boost::filesystem::system_complete(parResDir);
|
mResDir = boost::filesystem::system_complete(parResDir);
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
||||||
bool localOk = loadFromFile(localFilePath);
|
bool localOk = loadFromFile(localFilePath);
|
||||||
|
|
||||||
//user
|
//user
|
||||||
mUserFilePath = QString::fromStdString(mCfgMgr.getUserPath().string()) + fileName;
|
mUserFilePath = QString::fromStdString(mCfgMgr.getUserConfigPath().string()) + fileName;
|
||||||
loadFromFile(mUserFilePath);
|
loadFromFile(mUserFilePath);
|
||||||
|
|
||||||
if (!(localOk || globalOk))
|
if (!(localOk || globalOk))
|
||||||
|
|
|
@ -301,7 +301,7 @@ std::string OMW::Engine::loadSettings (Settings::Manager & settings)
|
||||||
throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed.");
|
throw std::runtime_error ("No default settings file found! Make sure the file \"settings-default.cfg\" was properly installed.");
|
||||||
|
|
||||||
// load user settings if they exist, otherwise just load the default settings as user settings
|
// load user settings if they exist, otherwise just load the default settings as user settings
|
||||||
const std::string settingspath = mCfgMgr.getUserPath().string() + "/settings.cfg";
|
const std::string settingspath = mCfgMgr.getUserConfigPath().string() + "/settings.cfg";
|
||||||
if (boost::filesystem::exists(settingspath))
|
if (boost::filesystem::exists(settingspath))
|
||||||
settings.loadUser(settingspath);
|
settings.loadUser(settingspath);
|
||||||
else if (boost::filesystem::exists(localdefault))
|
else if (boost::filesystem::exists(localdefault))
|
||||||
|
@ -373,7 +373,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
// Create input and UI first to set up a bootstrapping environment for
|
// Create input and UI first to set up a bootstrapping environment for
|
||||||
// showing a loading screen and keeping the window responsive while doing so
|
// showing a loading screen and keeping the window responsive while doing so
|
||||||
|
|
||||||
std::string keybinderUser = (mCfgMgr.getUserPath() / "input.xml").string();
|
std::string keybinderUser = (mCfgMgr.getUserConfigPath() / "input.xml").string();
|
||||||
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
bool keybinderUserExists = boost::filesystem::exists(keybinderUser);
|
||||||
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
|
MWInput::InputManager* input = new MWInput::InputManager (*mOgre, *this, keybinderUser, keybinderUserExists, mGrab);
|
||||||
mEnvironment.setInputManager (input);
|
mEnvironment.setInputManager (input);
|
||||||
|
@ -536,7 +536,7 @@ void OMW::Engine::screenshot()
|
||||||
// Count screenshots.
|
// Count screenshots.
|
||||||
int shotCount = 0;
|
int shotCount = 0;
|
||||||
|
|
||||||
const std::string screenshotPath = mCfgMgr.getUserPath().string();
|
const std::string& screenshotPath = mCfgMgr.getUserDataPath().string();
|
||||||
|
|
||||||
// Find the first unused filename with a do-while
|
// Find the first unused filename with a do-while
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
|
@ -27,6 +27,7 @@ ConfigurationManager::ConfigurationManager()
|
||||||
setupTokensMapping();
|
setupTokensMapping();
|
||||||
|
|
||||||
boost::filesystem::create_directories(mFixedPath.getUserConfigPath());
|
boost::filesystem::create_directories(mFixedPath.getUserConfigPath());
|
||||||
|
boost::filesystem::create_directories(mFixedPath.getUserDataPath());
|
||||||
|
|
||||||
mLogPath = mFixedPath.getUserConfigPath();
|
mLogPath = mFixedPath.getUserConfigPath();
|
||||||
}
|
}
|
||||||
|
@ -144,11 +145,16 @@ const boost::filesystem::path& ConfigurationManager::getGlobalPath() const
|
||||||
return mFixedPath.getGlobalConfigPath();
|
return mFixedPath.getGlobalConfigPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
const boost::filesystem::path& ConfigurationManager::getUserPath() const
|
const boost::filesystem::path& ConfigurationManager::getUserConfigPath() const
|
||||||
{
|
{
|
||||||
return mFixedPath.getUserConfigPath();
|
return mFixedPath.getUserConfigPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const boost::filesystem::path& ConfigurationManager::getUserDataPath() const
|
||||||
|
{
|
||||||
|
return mFixedPath.getUserDataPath();
|
||||||
|
}
|
||||||
|
|
||||||
const boost::filesystem::path& ConfigurationManager::getLocalPath() const
|
const boost::filesystem::path& ConfigurationManager::getLocalPath() const
|
||||||
{
|
{
|
||||||
return mFixedPath.getLocalPath();
|
return mFixedPath.getLocalPath();
|
||||||
|
|
|
@ -36,7 +36,7 @@ struct ConfigurationManager
|
||||||
|
|
||||||
/**< Fixed paths */
|
/**< Fixed paths */
|
||||||
const boost::filesystem::path& getGlobalPath() const;
|
const boost::filesystem::path& getGlobalPath() const;
|
||||||
const boost::filesystem::path& getUserPath() const;
|
const boost::filesystem::path& getUserConfigPath() const;
|
||||||
const boost::filesystem::path& getLocalPath() const;
|
const boost::filesystem::path& getLocalPath() const;
|
||||||
|
|
||||||
const boost::filesystem::path& getGlobalDataPath() const;
|
const boost::filesystem::path& getGlobalDataPath() const;
|
||||||
|
|
|
@ -48,7 +48,8 @@ struct FixedPath
|
||||||
*/
|
*/
|
||||||
FixedPath(const std::string& application_name)
|
FixedPath(const std::string& application_name)
|
||||||
: mPath(application_name + "/")
|
: mPath(application_name + "/")
|
||||||
, mUserPath(mPath.getUserConfigPath())
|
, mUserConfigPath(mPath.getUserConfigPath())
|
||||||
|
, mUserDataPath(mPath.getUserDataPath())
|
||||||
, mGlobalConfigPath(mPath.getGlobalConfigPath())
|
, mGlobalConfigPath(mPath.getGlobalConfigPath())
|
||||||
, mLocalPath(mPath.getLocalPath())
|
, mLocalPath(mPath.getLocalPath())
|
||||||
, mGlobalDataPath(mPath.getGlobalDataPath())
|
, mGlobalDataPath(mPath.getGlobalDataPath())
|
||||||
|
@ -59,18 +60,19 @@ struct FixedPath
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path pointing to the user local configuration directory.
|
* \brief Return path pointing to the user local configuration directory.
|
||||||
*
|
|
||||||
* \return boost::filesystem::path
|
|
||||||
*/
|
*/
|
||||||
const boost::filesystem::path& getUserConfigPath() const
|
const boost::filesystem::path& getUserConfigPath() const
|
||||||
{
|
{
|
||||||
return mUserPath;
|
return mUserConfigPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const boost::filesystem::path& getUserDataPath() const
|
||||||
|
{
|
||||||
|
return mUserDataPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path pointing to the global (system) configuration directory.
|
* \brief Return path pointing to the global (system) configuration directory.
|
||||||
*
|
|
||||||
* \return boost::filesystem::path
|
|
||||||
*/
|
*/
|
||||||
const boost::filesystem::path& getGlobalConfigPath() const
|
const boost::filesystem::path& getGlobalConfigPath() const
|
||||||
{
|
{
|
||||||
|
@ -79,8 +81,6 @@ struct FixedPath
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path pointing to the directory where application was started.
|
* \brief Return path pointing to the directory where application was started.
|
||||||
*
|
|
||||||
* \return boost::filesystem::path
|
|
||||||
*/
|
*/
|
||||||
const boost::filesystem::path& getLocalPath() const
|
const boost::filesystem::path& getLocalPath() const
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,8 @@ struct FixedPath
|
||||||
private:
|
private:
|
||||||
PathType mPath;
|
PathType mPath;
|
||||||
|
|
||||||
boost::filesystem::path mUserPath; /**< User path */
|
boost::filesystem::path mUserConfigPath; /**< User path */
|
||||||
|
boost::filesystem::path mUserDataPath;
|
||||||
boost::filesystem::path mGlobalConfigPath; /**< Global path */
|
boost::filesystem::path mGlobalConfigPath; /**< Global path */
|
||||||
boost::filesystem::path mLocalPath; /**< It is the same directory where application was run */
|
boost::filesystem::path mLocalPath; /**< It is the same directory where application was run */
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,39 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <boost/filesystem/fstream.hpp>
|
#include <boost/filesystem/fstream.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
boost::filesystem::path getUserHome()
|
||||||
|
{
|
||||||
|
const char* dir = getenv("HOME");
|
||||||
|
if (dir == NULL)
|
||||||
|
{
|
||||||
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
|
if (pwd != NULL)
|
||||||
|
{
|
||||||
|
dir = pwd->pw_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dir == NULL)
|
||||||
|
return boost::filesystem::path();
|
||||||
|
else
|
||||||
|
return boost::filesystem::path(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path getEnv(const std::string& envVariable, const boost::filesystem::path& fallback)
|
||||||
|
{
|
||||||
|
const char* result = getenv(envVariable.c_str());
|
||||||
|
if (!result)
|
||||||
|
return fallback;
|
||||||
|
boost::filesystem::path dir(result);
|
||||||
|
if (dir.empty())
|
||||||
|
return fallback;
|
||||||
|
else
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \namespace Files
|
* \namespace Files
|
||||||
*/
|
*/
|
||||||
|
@ -21,46 +54,17 @@ LinuxPath::LinuxPath(const std::string& application_name)
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getUserConfigPath() const
|
boost::filesystem::path LinuxPath::getUserConfigPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName;
|
||||||
|
}
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
boost::filesystem::path LinuxPath::getUserDataPath() const
|
||||||
if (theDir == NULL)
|
{
|
||||||
{
|
return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName;
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
|
||||||
if (pwd != NULL)
|
|
||||||
{
|
|
||||||
theDir = pwd->pw_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theDir != NULL)
|
|
||||||
{
|
|
||||||
userPath = boost::filesystem::path(theDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPath / ".config" / mName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getCachePath() const
|
boost::filesystem::path LinuxPath::getCachePath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName;
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
|
||||||
if (theDir == NULL)
|
|
||||||
{
|
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
|
||||||
if (pwd != NULL)
|
|
||||||
{
|
|
||||||
theDir = pwd->pw_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (theDir != NULL)
|
|
||||||
{
|
|
||||||
userPath = boost::filesystem::path(theDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPath / ".cache" / mName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getGlobalConfigPath() const
|
boost::filesystem::path LinuxPath::getGlobalConfigPath() const
|
||||||
|
@ -84,17 +88,9 @@ boost::filesystem::path LinuxPath::getInstallPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path installPath;
|
boost::filesystem::path installPath;
|
||||||
|
|
||||||
char *homePath = getenv("HOME");
|
boost::filesystem::path homePath = getUserHome();
|
||||||
if (homePath == NULL)
|
|
||||||
{
|
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
|
||||||
if (pwd != NULL)
|
|
||||||
{
|
|
||||||
homePath = pwd->pw_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (homePath != NULL)
|
if (!homePath.empty())
|
||||||
{
|
{
|
||||||
boost::filesystem::path wineDefaultRegistry(homePath);
|
boost::filesystem::path wineDefaultRegistry(homePath);
|
||||||
wineDefaultRegistry /= ".wine/system.reg";
|
wineDefaultRegistry /= ".wine/system.reg";
|
||||||
|
|
|
@ -23,6 +23,8 @@ struct LinuxPath
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path getUserConfigPath() const;
|
boost::filesystem::path getUserConfigPath() const;
|
||||||
|
|
||||||
|
boost::filesystem::path getUserDataPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path to the global (system) directory where config files can be placed.
|
* \brief Return path to the global (system) directory where config files can be placed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -11,9 +11,26 @@
|
||||||
* FIXME: Someone with MacOS system should check this and correct if necessary
|
* FIXME: Someone with MacOS system should check this and correct if necessary
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace
|
||||||
* \namespace Files
|
{
|
||||||
*/
|
boost::filesystem::path getUserHome()
|
||||||
|
{
|
||||||
|
const char* dir = getenv("HOME");
|
||||||
|
if (dir == NULL)
|
||||||
|
{
|
||||||
|
struct passwd* pwd = getpwuid(getuid());
|
||||||
|
if (pwd != NULL)
|
||||||
|
{
|
||||||
|
dir = pwd->pw_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dir == NULL)
|
||||||
|
return boost::filesystem::path();
|
||||||
|
else
|
||||||
|
return boost::filesystem::path(dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -24,21 +41,17 @@ MacOsPath::MacOsPath(const std::string& application_name)
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getUserConfigPath() const
|
boost::filesystem::path MacOsPath::getUserConfigPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath (getUserHome());
|
||||||
|
userPath /= "Library/Preferences/";
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
return userPath / mName;
|
||||||
if (theDir == NULL)
|
}
|
||||||
{
|
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
boost::filesystem::path MacOsPath::getUserDataPath() const
|
||||||
if (pwd != NULL)
|
{
|
||||||
{
|
// TODO: probably wrong?
|
||||||
theDir = pwd->pw_dir;
|
boost::filesystem::path userPath (getUserHome());
|
||||||
}
|
userPath /= "Library/Preferences/";
|
||||||
}
|
|
||||||
if (theDir != NULL)
|
|
||||||
{
|
|
||||||
userPath = boost::filesystem::path(theDir) / "Library/Preferences/";
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPath / mName;
|
return userPath / mName;
|
||||||
}
|
}
|
||||||
|
@ -51,23 +64,9 @@ boost::filesystem::path MacOsPath::getGlobalConfigPath() const
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getCachePath() const
|
boost::filesystem::path MacOsPath::getCachePath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath (getUserHome());
|
||||||
|
userPath /= "Library/Caches";
|
||||||
const char* theDir = getenv("HOME");
|
return userPath / mName;
|
||||||
if (theDir == NULL)
|
|
||||||
{
|
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
|
||||||
if (pwd != NULL)
|
|
||||||
{
|
|
||||||
theDir = pwd->pw_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (theDir != NULL)
|
|
||||||
{
|
|
||||||
userPath = boost::filesystem::path(theDir) / "Library/Caches" / mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
return userPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getLocalPath() const
|
boost::filesystem::path MacOsPath::getLocalPath() const
|
||||||
|
@ -85,17 +84,9 @@ boost::filesystem::path MacOsPath::getInstallPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path installPath;
|
boost::filesystem::path installPath;
|
||||||
|
|
||||||
char *homePath = getenv("HOME");
|
boost::filesystem::path homePath = getUserHome();
|
||||||
if (homePath == NULL)
|
|
||||||
{
|
|
||||||
struct passwd* pwd = getpwuid(getuid());
|
|
||||||
if (pwd != NULL)
|
|
||||||
{
|
|
||||||
homePath = pwd->pw_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (homePath != NULL)
|
if (!homePath.empty())
|
||||||
{
|
{
|
||||||
boost::filesystem::path wineDefaultRegistry(homePath);
|
boost::filesystem::path wineDefaultRegistry(homePath);
|
||||||
wineDefaultRegistry /= ".wine/system.reg";
|
wineDefaultRegistry /= ".wine/system.reg";
|
||||||
|
|
|
@ -25,6 +25,8 @@ struct MacOsPath
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path getUserConfigPath() const;
|
boost::filesystem::path getUserConfigPath() const;
|
||||||
|
|
||||||
|
boost::filesystem::path getUserDataPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path to the global (system) directory.
|
* \brief Return path to the global (system) directory.
|
||||||
*
|
*
|
||||||
|
|
|
@ -41,6 +41,12 @@ boost::filesystem::path WindowsPath::getUserConfigPath() const
|
||||||
return userPath / mName;
|
return userPath / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::filesystem::path WindowsPath::getUserDataPath() const
|
||||||
|
{
|
||||||
|
// Have some chaos, windows people!
|
||||||
|
return getUserConfigPath();
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path WindowsPath::getGlobalConfigPath() const
|
boost::filesystem::path WindowsPath::getGlobalConfigPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalPath(".");
|
boost::filesystem::path globalPath(".");
|
||||||
|
|
|
@ -31,6 +31,8 @@ struct WindowsPath
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path getUserConfigPath() const;
|
boost::filesystem::path getUserConfigPath() const;
|
||||||
|
|
||||||
|
boost::filesystem::path getUserDataPath() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns "X:\Program Files\"
|
* \brief Returns "X:\Program Files\"
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue