1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 17:59:56 +00:00
openmw/components/files/fixedpath.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
3.2 KiB
C++
Raw Normal View History

#ifndef COMPONENTS_FILES_FIXEDPATH_HPP
#define COMPONENTS_FILES_FIXEDPATH_HPP
#include <filesystem>
#include <string>
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
2014-08-06 03:48:16 +00:00
#ifndef ANDROID
#include <components/files/linuxpath.hpp>
namespace Files
{
typedef LinuxPath TargetPathType;
}
2014-08-05 20:54:53 +00:00
#else
2014-09-05 22:02:39 +00:00
#include <components/files/androidpath.hpp>
2014-08-05 20:46:21 +00:00
namespace Files
{
typedef AndroidPath TargetPathType;
}
2014-08-05 20:54:53 +00:00
#endif
#elif defined(__WIN32) || defined(__WINDOWS__) || defined(_WIN32)
#include <components/files/windowspath.hpp>
namespace Files
{
typedef WindowsPath TargetPathType;
}
#elif defined(macintosh) || defined(Macintosh) || defined(__APPLE__) || defined(__MACH__)
#include <components/files/macospath.hpp>
namespace Files
{
typedef MacOsPath TargetPathType;
}
#else
#error "Unknown platform!"
#endif
/**
* \namespace Files
*/
namespace Files
{
/**
* \struct Path
2022-09-22 18:26:05 +00:00
*
* \tparam P - Path strategy class type (depends on target system)
*
*/
template <class P = TargetPathType>
struct FixedPath
{
typedef P PathType;
2022-09-22 18:26:05 +00:00
/**
* \brief Path constructor.
2022-09-22 18:26:05 +00:00
*
* \param [in] application_name - Name of the application
2022-09-22 18:26:05 +00:00
*/
FixedPath(const std::string& application_name)
: mPath(application_name + "/")
2013-12-26 00:24:43 +00:00
, mUserConfigPath(mPath.getUserConfigPath())
, mUserDataPath(mPath.getUserDataPath())
2013-12-25 23:28:19 +00:00
, mGlobalConfigPath(mPath.getGlobalConfigPath())
, mLocalPath(mPath.getLocalPath())
, mGlobalDataPath(mPath.getGlobalDataPath())
2012-09-02 17:40:26 +00:00
, mCachePath(mPath.getCachePath())
2015-04-25 18:37:42 +00:00
, mInstallPath(mPath.getInstallPath())
2022-09-22 18:26:05 +00:00
{
}
/**
* \brief Return path pointing to the user local configuration directory.
2022-09-22 18:26:05 +00:00
*/
const std::filesystem::path& getUserConfigPath() const { return mUserConfigPath; }
2022-09-22 18:26:05 +00:00
const std::filesystem::path& getUserDataPath() const { return mUserDataPath; }
2022-09-22 18:26:05 +00:00
/**
* \brief Return path pointing to the global (system) configuration directory.
2022-09-22 18:26:05 +00:00
*/
const std::filesystem::path& getGlobalConfigPath() const { return mGlobalConfigPath; }
2022-09-22 18:26:05 +00:00
/**
* \brief Return path pointing to the directory where application was started.
2022-09-22 18:26:05 +00:00
*/
const std::filesystem::path& getLocalPath() const { return mLocalPath; }
2022-09-22 18:26:05 +00:00
const std::filesystem::path& getInstallPath() const { return mInstallPath; }
2022-09-22 18:26:05 +00:00
const std::filesystem::path& getGlobalDataPath() const { return mGlobalDataPath; }
2022-09-22 18:26:05 +00:00
const std::filesystem::path& getCachePath() const { return mCachePath; }
2012-09-02 17:40:26 +00:00
private:
PathType mPath;
std::filesystem::path mUserConfigPath; /**< User path */
std::filesystem::path mUserDataPath;
std::filesystem::path mGlobalConfigPath; /**< Global path */
std::filesystem::path mLocalPath; /**< It is the same directory where application was run */
std::filesystem::path mGlobalDataPath; /**< Global application data path */
std::filesystem::path mCachePath;
2012-09-02 17:40:26 +00:00
std::filesystem::path mInstallPath;
};
} /* namespace Files */
#endif /* COMPONENTS_FILES_FIXEDPATH_HPP */