33 #include <boost/filesystem.hpp>
35 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
47 return m_systemSettingsPath;
52 #if TE_PLATFORM == TE_PLATFORMCODE_MSWINDOWS
53 char userSettingsPath[MAX_PATH];
56 HRESULT result = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, userSettingsPath);
58 if((result == S_OK) && (userSettingsPath != 0) && boost::filesystem::is_directory(userSettingsPath))
59 m_userSettingsPath = userSettingsPath;
61 char systemSettingsPath[MAX_PATH];
63 result = SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, systemSettingsPath);
65 if((result == S_OK) && (systemSettingsPath != 0) && boost::filesystem::is_directory(systemSettingsPath))
66 m_systemSettingsPath = systemSettingsPath;
68 #elif TE_PLATFORM == TE_PLATFORMCODE_LINUX
69 const char* userSettingsPath = std::getenv(
"$HOME");
71 if((userSettingsPath != 0) && boost::filesystem::is_directory(userSettingsPath))
73 boost::filesystem::path p(userSettingsPath);
76 m_userSettingsPath = p.string();
79 if(boost::filesystem::is_directory(
"/etc/xdg"))
80 m_userSettingsPath =
"/etc/xdg";
82 #elif TE_PLATFORM == TE_PLATFORMCODE_APPLE
83 const char* userSettingsPath = std::getenv(
"$HOME");
85 if((userSettingsPath != 0) && boost::filesystem::is_directory(userSettingsPath))
87 boost::filesystem::path p(userSettingsPath);
90 m_userSettingsPath = p.string();
93 if(boost::filesystem::is_directory(
"/etc/xdg"))
94 m_userSettingsPath =
"/etc/xdg";
97 #error "Platform not supported! Contact TerraLib Team"
const std::string & getUserSettingsPath() const
It returns the folder location to store per user data.
A singleton class for discovering the Operational System settings directories.
OSSettingsDir()
It initializes the singleton.
~OSSettingsDir()
Destructor.
std::string m_userSettingsPath
Folder to output data by user.
const std::string & getSystemSettingsPath() const
It returns the folder location to store application data applied to all users.