MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / persistent_storage

Method persistent_storage

src/common/filesystem.cpp:208–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208persistent_storage::persistent_storage() {
209#ifndef _WIN32
210
211 auto get_home = [](std::string &home_out, std::string &subdirectory) -> bool {
212 if(const char* home = std::getenv("XDG_DATA_HOME")) {
213 home_out = home;
214 subdirectory = "acpp";
215 return true;
216 }
217
218 if (const char* home = std::getenv("HOME")) {
219 home_out = home;
220 subdirectory = ".acpp";
221 return true;
222 }
223
224 const char* home = getpwuid(getuid())->pw_dir;
225 if(home) {
226 home_out = home;
227 subdirectory = ".acpp";
228 return true;
229 }
230
231 return false;
232 };
233
234 if(!settings::try_retrieve_settings_variable("appdb_dir", _base_dir)) {
235 std::string home, subdirectory;
236 if (get_home(home, subdirectory)) {
237 _base_dir = (fs::path{home} / subdirectory).string();
238 } else {
239 _base_dir = (fs::current_path() / ".acpp").string();
240 }
241 }
242
243 std::string app_path = get_this_executable_path();
244 _this_app_dir = generate_app_dir(app_path);
245
246#else
247 _base_dir = (fs::current_path() / ".acpp").string();
248 _this_app_dir = (fs::path{_base_dir} / "apps" / "global").string();
249#endif
250
251 _jit_cache_dir = (fs::path{_this_app_dir} / "jit-cache").string();
252
253 fs::create_directories(_base_dir);
254 fs::create_directories(_this_app_dir);
255 fs::create_directories(_jit_cache_dir);
256
257#ifndef _WIN32
258 _this_app_db = std::make_unique<db::appdb>(generate_appdb_path(app_path));
259#else
260 _this_app_db = std::make_unique<db::appdb>(generate_appdb_path(""));
261#endif
262}
263
264std::string persistent_storage::generate_app_dir(const std::string& app_path) const {
265 std::string app_subdirectory = "global";

Callers

nothing calls this directly

Calls 2

get_this_executable_pathFunction · 0.85

Tested by

no test coverage detected