Mercurial > minori
comparison src/core/filesystem.cc @ 161:71752dcbb49f
junk: clunky merge commit
maybe I should enable rebase on this repo
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Fri, 17 Nov 2023 13:09:20 -0500 |
parents | 80d6b28eb29f |
children | 121c2d5b321f |
comparison
equal
deleted
inserted
replaced
160:900b5b530883 | 161:71752dcbb49f |
---|---|
25 namespace Filesystem { | 25 namespace Filesystem { |
26 | 26 |
27 /* this runs fs::create_directories() on the | 27 /* this runs fs::create_directories() on the |
28 PARENT directory. */ | 28 PARENT directory. */ |
29 void CreateDirectories(const std::filesystem::path& path) { | 29 void CreateDirectories(const std::filesystem::path& path) { |
30 std::filesystem::create_directories(path.parent_path()); | 30 if (path.empty()) |
31 return; | |
32 | |
33 const auto& parent = path.parent_path(); | |
34 if (!std::filesystem::exists(parent)) | |
35 std::filesystem::create_directories(parent); | |
31 } | 36 } |
32 | 37 |
33 std::filesystem::path GetDotPath() { | 38 std::filesystem::path GetDotPath() { |
34 #ifdef WIN32 | 39 #ifdef WIN32 |
35 std::filesystem::path path; | 40 std::filesystem::path path; |
47 const char* home = getenv("HOME"); | 52 const char* home = getenv("HOME"); |
48 # ifdef __linux__ | 53 # ifdef __linux__ |
49 if (!home) | 54 if (!home) |
50 home = getpwuid(getuid())->pw_dir; | 55 home = getpwuid(getuid())->pw_dir; |
51 # endif // __linux__ | 56 # endif // __linux__ |
52 if (!home) | 57 if (home) |
53 return std::filesystem::path(home) / ".config"; | 58 return std::filesystem::path(home) / ".config" / CONFIG_DIR; |
54 else | 59 else |
55 return std::filesystem::path(); | 60 return std::filesystem::path(); |
56 #endif // !WIN32 && !MACOSX | 61 #endif // !WIN32 && !MACOSX |
57 } | 62 } |
58 | 63 |