Skip to content

Commit c1c9655

Browse files
committed
mkdir -p before calling environmentInit()
1 parent 879a031 commit c1c9655

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ static void initLocale(QTranslator *qtTranslator, QTranslator *translator)
4848

4949
void initConfig(std::string &configFile)
5050
{
51-
// mkdir -p
52-
if (!std::filesystem::exists(configFile)) {
53-
size_t filenamePosition = configFile.find_last_of("/");
54-
std::string dirname = configFile.substr(0, filenamePosition);
55-
info("Creating directory '{}'", dirname);
56-
std::filesystem::create_directories(dirname);
57-
}
58-
5951
bool success = xml_init(configFile.data());
6052

6153
if (!success) {
@@ -68,6 +60,14 @@ void initConfig(std::string &configFile)
6860
}
6961
}
7062

63+
void mkdir_p(std::string path)
64+
{
65+
if (!std::filesystem::exists(path)) {
66+
info("Creating directory '{}'", path);
67+
std::filesystem::create_directories(path);
68+
}
69+
}
70+
7171
int main(int argc, char *argv[])
7272
{
7373
QApplication app(argc, argv);
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
7979
std::string config_home = std::getenv("HOME") + std::string("/.config/labwc");
8080
std::string config_dir = std::getenv("LABWC_CONFIG_DIR") ?: config_home;
8181

82-
// TODO: do the mkdir -p here
82+
mkdir_p(config_dir);
8383

8484
std::string environment_file = config_dir + "/environment";
8585
environmentInit(environment_file);

0 commit comments

Comments
 (0)