@@ -78,16 +78,6 @@ std::filesystem::path GetHomeDirectoryPath() {
78
78
return std::filesystem::path (homeDir);
79
79
}
80
80
81
- // Helper function to get XDG base directory, falling back to default if not set
82
- std::filesystem::path GetXDGDirectoryPath (const std::string& envVar,
83
- const std::string& defaultPath) {
84
- if (const char * envValue = std::getenv (envVar.c_str ());
85
- envValue && std::strlen (envValue) > 0 ) {
86
- return std::filesystem::path (envValue);
87
- }
88
- return GetHomeDirectoryPath () / defaultPath;
89
- }
90
-
91
81
std::filesystem::path GetConfigurationPath () {
92
82
#ifndef CORTEX_CONFIG_FILE_PATH
93
83
#define CORTEX_CONFIG_FILE_PATH kDefaultConfigurationPath
@@ -123,14 +113,9 @@ std::filesystem::path GetConfigurationPath() {
123
113
std::string config_file_name{kCortexConfigurationFileName };
124
114
config_file_name.append (env_postfix);
125
115
// CTL_INF("Config file name: " + config_file_name);
126
- #if defined(__linux__)
127
- auto config_base_path =
128
- GetXDGDirectoryPath (" XDG_CONFIG_HOME" , " .config" ) / kCortexFolderName ;
129
- auto configuration_path = config_base_path / config_file_name;
130
- #else
116
+
131
117
auto home_path = GetHomeDirectoryPath ();
132
118
auto configuration_path = home_path / config_file_name;
133
- #endif
134
119
return configuration_path;
135
120
}
136
121
@@ -165,20 +150,11 @@ cpp::result<void, std::string> UpdateCortexConfig(
165
150
config_yaml_utils::CortexConfig GetDefaultConfig () {
166
151
auto config_path = GetConfigurationPath ();
167
152
auto default_data_folder_name = GetDefaultDataFolderName ();
168
- #if defined(__linux__)
169
- auto default_data_folder_path =
170
- cortex_data_folder_path.empty ()
171
- ? file_manager_utils::GetXDGDirectoryPath (" XDG_DATA_HOME" ,
172
- " .local/share" ) /
173
- default_data_folder_name
174
- : std::filesystem::path (cortex_data_folder_path);
175
- #else
176
153
auto default_data_folder_path =
177
154
cortex_data_folder_path.empty ()
178
155
? file_manager_utils::GetHomeDirectoryPath () /
179
156
default_data_folder_name
180
157
: std::filesystem::path (cortex_data_folder_path);
181
- #endif
182
158
183
159
return config_yaml_utils::CortexConfig{
184
160
#if defined(_WIN32)
@@ -228,10 +204,6 @@ cpp::result<void, std::string> CreateConfigFileIfNotExist() {
228
204
// already exists, no need to create
229
205
return {};
230
206
}
231
- if (!std::filesystem::exists (config_path.parent_path ())) {
232
- // Ensure the configuration directory exists
233
- std::filesystem::create_directories (config_path.parent_path ());
234
- }
235
207
236
208
CLI_LOG (" Config file not found. Creating one at " + config_path.string ());
237
209
auto config = GetDefaultConfig ();
@@ -264,13 +236,8 @@ std::filesystem::path GetCortexDataPath() {
264
236
data_folder_path = std::filesystem::path (config.dataFolderPath );
265
237
#endif
266
238
} else {
267
- #if defined(__linux__)
268
- auto data_base_path = GetXDGDirectoryPath (" XDG_DATA_HOME" , " .local/share" );
269
- data_folder_path = data_base_path / GetDefaultDataFolderName ();
270
- #else
271
239
auto home_path = GetHomeDirectoryPath ();
272
240
data_folder_path = home_path / kCortexFolderName ;
273
- #endif
274
241
}
275
242
276
243
if (!std::filesystem::exists (data_folder_path)) {
@@ -286,19 +253,13 @@ std::filesystem::path GetCortexLogPath() {
286
253
// TODO: get the variant of cortex. As discussed, we will have: prod, beta, nightly
287
254
288
255
// currently we will store cortex data at ~/cortexcpp
289
- // On linux, we follow the xdg directory specification
290
256
auto config = GetCortexConfig ();
291
257
std::filesystem::path log_folder_path;
292
258
if (!config.logFolderPath .empty ()) {
293
259
log_folder_path = std::filesystem::path (config.logFolderPath );
294
260
} else {
295
- #if defined(__linux__)
296
- auto data_base_path = GetXDGDirectoryPath (" XDG_DATA_HOME" , " .local/share" );
297
- log_folder_path = data_base_path / GetDefaultDataFolderName () / " logs" ;
298
- #else
299
261
auto home_path = GetHomeDirectoryPath ();
300
262
log_folder_path = home_path / kCortexFolderName ;
301
- #endif
302
263
}
303
264
304
265
if (!std::filesystem::exists (log_folder_path)) {
0 commit comments