diff options
author | Jim Posen <jim.posen@gmail.com> | 2018-09-01 15:18:02 -0700 |
---|---|---|
committer | Jim Posen <jim.posen@gmail.com> | 2019-02-22 17:38:45 -0800 |
commit | 62e7addb632cad77cbd5fbccbaee51c7b32505d0 (patch) | |
tree | d1251329ff8b5fc6dd6c85a0fdee883d66736f0e /src/util/system.cpp | |
parent | f3f9c1de19e6d254e0c3a26ce7a3d8cd57fb7641 (diff) |
util: Move CheckDiskSpace to util.
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r-- | src/util/system.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp index 6e82de743a..3e6c2ae5d4 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -135,6 +135,14 @@ bool DirIsWritable(const fs::path& directory) return true; } +bool CheckDiskSpace(const fs::path& dir, uint64_t nAdditionalBytes) +{ + constexpr uint64_t nMinDiskSpace = 52428800; // 50 MiB + + uint64_t nFreeBytesAvailable = fs::space(dir).available; + return nFreeBytesAvailable >= nMinDiskSpace + nAdditionalBytes; +} + /** * Interpret a string argument as a boolean. * |