Enhance config directory handling and improve platform-specific path management
This commit is contained in:
@@ -347,7 +347,10 @@ absl::Status Controller::LoadConfigFiles() {
|
|||||||
|
|
||||||
// Create the directory if it doesn't exist
|
// Create the directory if it doesn't exist
|
||||||
if (!std::filesystem::exists(config_directory)) {
|
if (!std::filesystem::exists(config_directory)) {
|
||||||
std::filesystem::create_directory(config_directory);
|
if (!std::filesystem::create_directory(config_directory)) {
|
||||||
|
return absl::InternalError(absl::StrFormat(
|
||||||
|
"Failed to create config directory %s", config_directory));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the config file exists
|
// Check if the config file exists
|
||||||
@@ -359,6 +362,7 @@ absl::Status Controller::LoadConfigFiles() {
|
|||||||
return absl::InternalError(
|
return absl::InternalError(
|
||||||
absl::StrFormat("Failed to create config file %s", config_file));
|
absl::StrFormat("Failed to create config file %s", config_file));
|
||||||
}
|
}
|
||||||
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
|
|||||||
@@ -56,21 +56,19 @@ void SaveFile(const std::string &filename, const std::string &contents,
|
|||||||
std::string GetConfigDirectory(Platform platform) {
|
std::string GetConfigDirectory(Platform platform) {
|
||||||
std::string config_directory = ".yaze";
|
std::string config_directory = ".yaze";
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case Platform::kMacOS:
|
case Platform::kWindows:
|
||||||
config_directory = "~/Library/Application Support/yaze";
|
config_directory = "~/AppData/Roaming/yaze";
|
||||||
break;
|
break;
|
||||||
case Platform::kWindows:
|
case Platform::kMacOS:
|
||||||
config_directory = "~/AppData/Roaming/yaze";
|
case Platform::kLinux:
|
||||||
break;
|
config_directory = "~/.config/yaze";
|
||||||
case Platform::kLinux:
|
break;
|
||||||
config_directory = "~/.config/yaze";
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return config_directory;
|
return config_directory;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace core
|
} // namespace core
|
||||||
} // namespace app
|
} // namespace app
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
Reference in New Issue
Block a user