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
|
||||
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
|
||||
@@ -359,6 +362,7 @@ absl::Status Controller::LoadConfigFiles() {
|
||||
return absl::InternalError(
|
||||
absl::StrFormat("Failed to create config file %s", config_file));
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
|
||||
@@ -56,21 +56,19 @@ void SaveFile(const std::string &filename, const std::string &contents,
|
||||
std::string GetConfigDirectory(Platform platform) {
|
||||
std::string config_directory = ".yaze";
|
||||
switch (platform) {
|
||||
case Platform::kMacOS:
|
||||
config_directory = "~/Library/Application Support/yaze";
|
||||
break;
|
||||
case Platform::kWindows:
|
||||
config_directory = "~/AppData/Roaming/yaze";
|
||||
break;
|
||||
case Platform::kLinux:
|
||||
config_directory = "~/.config/yaze";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case Platform::kWindows:
|
||||
config_directory = "~/AppData/Roaming/yaze";
|
||||
break;
|
||||
case Platform::kMacOS:
|
||||
case Platform::kLinux:
|
||||
config_directory = "~/.config/yaze";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return config_directory;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
} // namespace core
|
||||
} // namespace app
|
||||
} // namespace yaze
|
||||
|
||||
Reference in New Issue
Block a user