diff options
| author | Hennadii Stepanov <[email protected]> | 2020-10-16 18:06:14 +0300 |
|---|---|---|
| committer | Hennadii Stepanov <[email protected]> | 2020-10-27 21:45:32 +0200 |
| commit | b19e88230f0e93e95e883e65376963cb9c36f606 (patch) | |
| tree | d50c41eec352973eccc262981958d8dbc1802aaf /src/util | |
| parent | Merge bitcoin-core/gui#97: Relax GUI freezes during IBD (when using wallets) (diff) | |
| download | discoin-b19e88230f0e93e95e883e65376963cb9c36f606.tar.xz discoin-b19e88230f0e93e95e883e65376963cb9c36f606.zip | |
util: Add StripRedundantLastElementsOfPath function
Co-authored-by: saibato <[email protected]>
Co-authored-by: MarcoFalke <[email protected]>
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/system.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index a411b73a1..7754ef3e0 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -34,6 +34,7 @@ #endif // __linux__ #include <algorithm> +#include <cassert> #include <fcntl.h> #include <sched.h> #include <sys/resource.h> @@ -665,6 +666,19 @@ fs::path GetDefaultDataDir() #endif } +namespace { +fs::path StripRedundantLastElementsOfPath(const fs::path& path) +{ + auto result = path; + while (result.filename().string() == ".") { + result = result.parent_path(); + } + + assert(fs::equivalent(result, path)); + return result; +} +} // namespace + static fs::path g_blocks_path_cache_net_specific; static fs::path pathCached; static fs::path pathCachedNetSpecific; @@ -692,6 +706,7 @@ const fs::path &GetBlocksDir() path /= BaseParams().DataDir(); path /= "blocks"; fs::create_directories(path); + path = StripRedundantLastElementsOfPath(path); return path; } @@ -722,6 +737,7 @@ const fs::path &GetDataDir(bool fNetSpecific) fs::create_directories(path / "wallets"); } + path = StripRedundantLastElementsOfPath(path); return path; } |