mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 16:06:00 +01:00
Create config directory if it doesn't exist
This commit is contained in:
parent
fa6530c7e8
commit
0c5d2f04b4
1 changed files with 11 additions and 1 deletions
|
@ -654,7 +654,8 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
configPaths.clear();
|
configPaths.clear();
|
||||||
|
|
||||||
static const char* const ENVHOME = getenv("HOME");
|
static const char* const ENVHOME = getenv("HOME");
|
||||||
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
||||||
|
const std::string CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
||||||
|
|
||||||
configPaths.push_back(CONFIGPATH);
|
configPaths.push_back(CONFIGPATH);
|
||||||
|
|
||||||
|
@ -667,6 +668,15 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||||
} catch(...) { /* Probably doesn't exist */}
|
} catch(...) { /* Probably doesn't exist */}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
||||||
|
std::filesystem::create_directories(CONFIGPARENTPATH);
|
||||||
|
}
|
||||||
|
catch (...) {
|
||||||
|
parseError = "Broken config file! (Could not create directory)";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
ofs.open(CONFIGPATH, std::ios::trunc);
|
ofs.open(CONFIGPATH, std::ios::trunc);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue