Skip to content
Snippets Groups Projects
Commit e78daee3 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

file system: create folders if they don't exist

Change-Id: Ie84e5301a8726ef7652197c0fa5b771c94a4bdec
parent 9be562fa
No related branches found
No related tags found
No related merge requests found
...@@ -381,8 +381,14 @@ get_cache_dir() ...@@ -381,8 +381,14 @@ get_cache_dir()
std::vector<std::string> paths; std::vector<std::string> paths;
emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths); emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths);
if (not paths.empty()) if (not paths.empty())
cache_path = paths[0]; cache_path = paths[0] + DIR_SEPARATOR_STR + std::string(".cache");
return cache_path + DIR_SEPARATOR_STR + std::string(".cache");
if (fileutils::recursive_mkdir(cache_path.data(), 0700) != true) {
// If directory creation failed
if (errno != EEXIST)
RING_DBG("Cannot create directory: %s!", cache_path.c_str());
}
return cache_path;
#else #else
const std::string cache_home(XDG_CACHE_HOME); const std::string cache_home(XDG_CACHE_HOME);
...@@ -470,8 +476,14 @@ get_data_dir() ...@@ -470,8 +476,14 @@ get_data_dir()
std::vector<std::string> paths; std::vector<std::string> paths;
emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths); emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths);
if (not paths.empty()) if (not paths.empty())
files_path = paths[0]; files_path = paths[0] + DIR_SEPARATOR_STR + std::string(".data");
return files_path + DIR_SEPARATOR_STR + std::string(".data");
if (fileutils::recursive_mkdir(files_path.data(), 0700) != true) {
// If directory creation failed
if (errno != EEXIST)
RING_DBG("Cannot create directory: %s!", files_path.c_str());
}
return files_path;
#else #else
const std::string data_home(XDG_DATA_HOME); const std::string data_home(XDG_DATA_HOME);
if (not data_home.empty()) if (not data_home.empty())
...@@ -501,8 +513,14 @@ get_config_dir() ...@@ -501,8 +513,14 @@ get_config_dir()
std::vector<std::string> paths; std::vector<std::string> paths;
emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths); emitSignal<DRing::ConfigurationSignal::GetAppDataPath>(&paths);
if (not paths.empty()) if (not paths.empty())
files_path = paths[0]; config_path = paths[0] + DIR_SEPARATOR_STR + std::string(".config");
return files_path + DIR_SEPARATOR_STR + std::string(".config");
if (fileutils::recursive_mkdir(config_path.data(), 0700) != true) {
// If directory creation failed
if (errno != EEXIST)
RING_DBG("Cannot create directory: %s!", config_path.c_str());
}
return config_path;
#else #else
std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR + std::string configdir = fileutils::get_home_dir() + DIR_SEPARATOR_STR +
".config" + DIR_SEPARATOR_STR + PACKAGE; ".config" + DIR_SEPARATOR_STR + PACKAGE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment