forked from mirror/openmw-tes3mp
Testing a third way to solve the path issue
This commit is contained in:
parent
6e317f00eb
commit
97f1be2b05
7 changed files with 45 additions and 24 deletions
|
@ -69,7 +69,7 @@ struct FixedPath
|
||||||
* \param [in] application_name - Name of the application
|
* \param [in] application_name - Name of the application
|
||||||
*/
|
*/
|
||||||
FixedPath(const std::string& application_name)
|
FixedPath(const std::string& application_name)
|
||||||
: mPath()
|
: mPath(application_name)
|
||||||
, mUserPath(mPath.getUserPath())
|
, mUserPath(mPath.getUserPath())
|
||||||
, mGlobalPath(mPath.getGlobalPath())
|
, mGlobalPath(mPath.getGlobalPath())
|
||||||
, mLocalPath(mPath.getLocalPath())
|
, mLocalPath(mPath.getLocalPath())
|
||||||
|
@ -77,18 +77,6 @@ struct FixedPath
|
||||||
, mInstallPath(mPath.getInstallPath())
|
, mInstallPath(mPath.getInstallPath())
|
||||||
, mCachePath(mPath.getCachePath())
|
, mCachePath(mPath.getCachePath())
|
||||||
{
|
{
|
||||||
if (!application_name.empty())
|
|
||||||
{
|
|
||||||
boost::filesystem::path suffix(application_name + std::string("/"));
|
|
||||||
|
|
||||||
mUserPath /= suffix;
|
|
||||||
mGlobalPath /= suffix;
|
|
||||||
mGlobalDataPath /= suffix;
|
|
||||||
mCachePath /= suffix;
|
|
||||||
#ifdef _WIN32
|
|
||||||
mCachePath /= "cache";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,10 +36,15 @@
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LinuxPath::LinuxPath(const std::string& application_name)
|
||||||
|
: mName(application_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getUserPath() const
|
boost::filesystem::path LinuxPath::getUserPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath(".");
|
||||||
boost::filesystem::path suffix("/");
|
boost::filesystem::path suffix(mName);
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
const char* theDir = getenv("HOME");
|
||||||
if (theDir == NULL)
|
if (theDir == NULL)
|
||||||
|
@ -65,6 +70,7 @@ boost::filesystem::path LinuxPath::getUserPath() const
|
||||||
boost::filesystem::path LinuxPath::getCachePath() const
|
boost::filesystem::path LinuxPath::getCachePath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath(".");
|
||||||
|
boost::filesystem::path suffix(mName);
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
const char* theDir = getenv("HOME");
|
||||||
if (theDir == NULL)
|
if (theDir == NULL)
|
||||||
|
@ -80,7 +86,7 @@ boost::filesystem::path LinuxPath::getCachePath() const
|
||||||
{
|
{
|
||||||
userPath = boost::filesystem::path(theDir);
|
userPath = boost::filesystem::path(theDir);
|
||||||
}
|
}
|
||||||
userPath /= ".cache";
|
userPath /= ".cache" / suffix;
|
||||||
|
|
||||||
return userPath;
|
return userPath;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +94,7 @@ boost::filesystem::path LinuxPath::getCachePath() const
|
||||||
boost::filesystem::path LinuxPath::getGlobalPath() const
|
boost::filesystem::path LinuxPath::getGlobalPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalPath("/etc/");
|
boost::filesystem::path globalPath("/etc/");
|
||||||
return globalPath;
|
return globalPath / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getLocalPath() const
|
boost::filesystem::path LinuxPath::getLocalPath() const
|
||||||
|
@ -99,7 +105,7 @@ boost::filesystem::path LinuxPath::getLocalPath() const
|
||||||
boost::filesystem::path LinuxPath::getGlobalDataPath() const
|
boost::filesystem::path LinuxPath::getGlobalDataPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalDataPath("/usr/share/games/");
|
boost::filesystem::path globalDataPath("/usr/share/games/");
|
||||||
return globalDataPath;
|
return globalDataPath / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path LinuxPath::getInstallPath() const
|
boost::filesystem::path LinuxPath::getInstallPath() const
|
||||||
|
|
|
@ -38,6 +38,8 @@ namespace Files
|
||||||
*/
|
*/
|
||||||
struct LinuxPath
|
struct LinuxPath
|
||||||
{
|
{
|
||||||
|
LinuxPath(const std::string& application_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path to the user directory.
|
* \brief Return path to the user directory.
|
||||||
*
|
*
|
||||||
|
@ -80,6 +82,8 @@ struct LinuxPath
|
||||||
* \return boost::filesystem::path
|
* \return boost::filesystem::path
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path getInstallPath() const;
|
boost::filesystem::path getInstallPath() const;
|
||||||
|
|
||||||
|
std::string mName;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Files */
|
} /* namespace Files */
|
||||||
|
|
|
@ -39,10 +39,15 @@
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
|
|
||||||
|
MacOsPath::MacOsPath(const std::string& application_name)
|
||||||
|
: mName(application_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getUserPath() const
|
boost::filesystem::path MacOsPath::getUserPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath(".");
|
||||||
boost::filesystem::path suffix("/");
|
boost::filesystem::path suffix(mName);
|
||||||
|
|
||||||
const char* theDir = getenv("HOME");
|
const char* theDir = getenv("HOME");
|
||||||
if (theDir == NULL)
|
if (theDir == NULL)
|
||||||
|
@ -66,7 +71,7 @@ boost::filesystem::path MacOsPath::getUserPath() const
|
||||||
boost::filesystem::path MacOsPath::getGlobalPath() const
|
boost::filesystem::path MacOsPath::getGlobalPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalPath("/Library/Preferences/");
|
boost::filesystem::path globalPath("/Library/Preferences/");
|
||||||
return globalPath;
|
return globalPath / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getCachePath() const
|
boost::filesystem::path MacOsPath::getCachePath() const
|
||||||
|
@ -84,7 +89,7 @@ boost::filesystem::path MacOsPath::getCachePath() const
|
||||||
}
|
}
|
||||||
if (theDir != NULL)
|
if (theDir != NULL)
|
||||||
{
|
{
|
||||||
userPath = boost::filesystem::path(theDir) / "Library/Caches";
|
userPath = boost::filesystem::path(theDir) / "Library/Caches" / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return userPath;
|
return userPath;
|
||||||
|
@ -98,7 +103,7 @@ boost::filesystem::path MacOsPath::getLocalPath() const
|
||||||
boost::filesystem::path MacOsPath::getGlobalDataPath() const
|
boost::filesystem::path MacOsPath::getGlobalDataPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalDataPath("/Library/Application Support/");
|
boost::filesystem::path globalDataPath("/Library/Application Support/");
|
||||||
return globalDataPath;
|
return globalDataPath / mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path MacOsPath::getInstallPath() const
|
boost::filesystem::path MacOsPath::getInstallPath() const
|
||||||
|
|
|
@ -38,6 +38,8 @@ namespace Files
|
||||||
*/
|
*/
|
||||||
struct MacOsPath
|
struct MacOsPath
|
||||||
{
|
{
|
||||||
|
MacOsPath(const std::string& application_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return path to the local directory.
|
* \brief Return path to the local directory.
|
||||||
*
|
*
|
||||||
|
@ -75,6 +77,8 @@ struct MacOsPath
|
||||||
boost::filesystem::path getGlobalDataPath() const;
|
boost::filesystem::path getGlobalDataPath() const;
|
||||||
|
|
||||||
boost::filesystem::path getInstallPath() const;
|
boost::filesystem::path getInstallPath() const;
|
||||||
|
|
||||||
|
std::string mName;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Files */
|
} /* namespace Files */
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
namespace Files
|
namespace Files
|
||||||
{
|
{
|
||||||
|
|
||||||
|
WindowsPath::WindowsPath(const std::string& application_name)
|
||||||
|
: mName(application_name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
boost::filesystem::path WindowsPath::getUserPath() const
|
boost::filesystem::path WindowsPath::getUserPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path userPath(".");
|
boost::filesystem::path userPath(".");
|
||||||
boost::filesystem::path suffix("/");
|
boost::filesystem::path suffix(mName);
|
||||||
|
|
||||||
TCHAR path[MAX_PATH];
|
TCHAR path[MAX_PATH];
|
||||||
memset(path, 0, sizeof(path));
|
memset(path, 0, sizeof(path));
|
||||||
|
@ -42,7 +47,7 @@ boost::filesystem::path WindowsPath::getUserPath() const
|
||||||
boost::filesystem::path WindowsPath::getGlobalPath() const
|
boost::filesystem::path WindowsPath::getGlobalPath() const
|
||||||
{
|
{
|
||||||
boost::filesystem::path globalPath(".");
|
boost::filesystem::path globalPath(".");
|
||||||
boost::filesystem::path suffix("/");
|
boost::filesystem::path suffix(mName);
|
||||||
|
|
||||||
TCHAR path[MAX_PATH];
|
TCHAR path[MAX_PATH];
|
||||||
memset(path, 0, sizeof(path));
|
memset(path, 0, sizeof(path));
|
||||||
|
@ -69,7 +74,7 @@ boost::filesystem::path WindowsPath::getGlobalDataPath() const
|
||||||
|
|
||||||
boost::filesystem::path WindowsPath::getCachePath() const
|
boost::filesystem::path WindowsPath::getCachePath() const
|
||||||
{
|
{
|
||||||
return getUserPath();
|
return getUserPath() / "cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::filesystem::path WindowsPath::getInstallPath() const
|
boost::filesystem::path WindowsPath::getInstallPath() const
|
||||||
|
|
|
@ -38,6 +38,13 @@ namespace Files
|
||||||
*/
|
*/
|
||||||
struct WindowsPath
|
struct WindowsPath
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* \brief WindowsPath constructor.
|
||||||
|
*
|
||||||
|
* \param [in] application_name - The name of the application.
|
||||||
|
*/
|
||||||
|
WindowsPath(const std::string& application_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns user path i.e.:
|
* \brief Returns user path i.e.:
|
||||||
* "X:\Documents And Settings\<User name>\My Documents\My Games\"
|
* "X:\Documents And Settings\<User name>\My Documents\My Games\"
|
||||||
|
@ -81,6 +88,8 @@ struct WindowsPath
|
||||||
* \return boost::filesystem::path
|
* \return boost::filesystem::path
|
||||||
*/
|
*/
|
||||||
boost::filesystem::path getInstallPath() const;
|
boost::filesystem::path getInstallPath() const;
|
||||||
|
|
||||||
|
std::string mName;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Files */
|
} /* namespace Files */
|
||||||
|
|
Loading…
Reference in a new issue