2012-01-21 00:14:35 +00:00
|
|
|
#ifndef COMPONENTS_FILES_FIXEDPATH_HPP
|
|
|
|
#define COMPONENTS_FILES_FIXEDPATH_HPP
|
2011-01-04 00:34:55 +00:00
|
|
|
|
|
|
|
#include <string>
|
2011-08-19 19:06:09 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
2016-08-06 18:00:27 +00:00
|
|
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
|
2014-08-06 03:48:16 +00:00
|
|
|
#ifndef ANDROID
|
2011-08-19 19:06:09 +00:00
|
|
|
#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
|
2012-02-23 19:06:06 +00:00
|
|
|
#elif defined(__WIN32) || defined(__WINDOWS__) || defined(_WIN32)
|
2011-08-19 19:06:09 +00:00
|
|
|
#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
|
|
|
|
*/
|
2011-04-28 07:56:50 +00:00
|
|
|
namespace Files
|
2011-01-04 00:34:55 +00:00
|
|
|
{
|
2011-08-19 19:06:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \struct Path
|
|
|
|
*
|
|
|
|
* \tparam P - Path strategy class type (depends on target system)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
template
|
|
|
|
<
|
|
|
|
class P = TargetPathType
|
|
|
|
>
|
2012-01-21 00:14:35 +00:00
|
|
|
struct FixedPath
|
2011-08-19 19:06:09 +00:00
|
|
|
{
|
|
|
|
typedef P PathType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Path constructor.
|
|
|
|
*
|
|
|
|
* \param [in] application_name - Name of the application
|
|
|
|
*/
|
2012-01-21 00:14:35 +00:00
|
|
|
FixedPath(const std::string& application_name)
|
2012-09-09 14:28:02 +00:00
|
|
|
: 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())
|
2012-01-21 00:14:35 +00:00
|
|
|
, mLocalPath(mPath.getLocalPath())
|
2012-01-21 16:58:49 +00:00
|
|
|
, 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())
|
2011-01-04 00:34:55 +00:00
|
|
|
{
|
2011-08-19 19:06:09 +00:00
|
|
|
}
|
2014-08-06 03:48:16 +00:00
|
|
|
|
2011-08-19 19:06:09 +00:00
|
|
|
/**
|
|
|
|
* \brief Return path pointing to the user local configuration directory.
|
|
|
|
*/
|
2013-12-25 23:28:19 +00:00
|
|
|
const boost::filesystem::path& getUserConfigPath() const
|
2011-08-19 19:06:09 +00:00
|
|
|
{
|
2013-12-26 00:24:43 +00:00
|
|
|
return mUserConfigPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
const boost::filesystem::path& getUserDataPath() const
|
|
|
|
{
|
|
|
|
return mUserDataPath;
|
2011-08-19 19:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Return path pointing to the global (system) configuration directory.
|
|
|
|
*/
|
2013-12-25 23:28:19 +00:00
|
|
|
const boost::filesystem::path& getGlobalConfigPath() const
|
2011-08-19 19:06:09 +00:00
|
|
|
{
|
2013-12-25 23:28:19 +00:00
|
|
|
return mGlobalConfigPath;
|
2011-08-19 19:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Return path pointing to the directory where application was started.
|
|
|
|
*/
|
2012-01-21 00:14:35 +00:00
|
|
|
const boost::filesystem::path& getLocalPath() const
|
2011-08-19 19:06:09 +00:00
|
|
|
{
|
2012-01-21 00:14:35 +00:00
|
|
|
return mLocalPath;
|
2011-08-19 19:06:09 +00:00
|
|
|
}
|
|
|
|
|
2014-08-06 03:48:16 +00:00
|
|
|
|
2012-01-21 16:58:49 +00:00
|
|
|
const boost::filesystem::path& getInstallPath() const
|
2011-08-19 19:06:09 +00:00
|
|
|
{
|
2012-01-25 22:55:43 +00:00
|
|
|
return mInstallPath;
|
|
|
|
}
|
2014-08-06 03:48:16 +00:00
|
|
|
|
2011-08-19 19:06:09 +00:00
|
|
|
const boost::filesystem::path& getGlobalDataPath() const
|
|
|
|
{
|
|
|
|
return mGlobalDataPath;
|
|
|
|
}
|
|
|
|
|
2012-09-02 17:40:26 +00:00
|
|
|
const boost::filesystem::path& getCachePath() const
|
|
|
|
{
|
|
|
|
return mCachePath;
|
|
|
|
}
|
|
|
|
|
2011-08-19 19:06:09 +00:00
|
|
|
private:
|
|
|
|
PathType mPath;
|
|
|
|
|
2013-12-26 00:24:43 +00:00
|
|
|
boost::filesystem::path mUserConfigPath; /**< User path */
|
|
|
|
boost::filesystem::path mUserDataPath;
|
2013-12-25 23:28:19 +00:00
|
|
|
boost::filesystem::path mGlobalConfigPath; /**< Global path */
|
2012-01-21 00:14:35 +00:00
|
|
|
boost::filesystem::path mLocalPath; /**< It is the same directory where application was run */
|
2011-08-19 19:06:09 +00:00
|
|
|
|
2012-01-21 16:58:49 +00:00
|
|
|
boost::filesystem::path mGlobalDataPath; /**< Global application data path */
|
2012-02-19 22:39:37 +00:00
|
|
|
|
2012-09-02 17:40:26 +00:00
|
|
|
boost::filesystem::path mCachePath;
|
|
|
|
|
2012-01-21 16:58:49 +00:00
|
|
|
boost::filesystem::path mInstallPath;
|
2011-08-19 19:06:09 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} /* namespace Files */
|
|
|
|
|
2012-01-21 00:14:35 +00:00
|
|
|
#endif /* COMPONENTS_FILES_FIXEDPATH_HPP */
|