util: Move CheckDiskSpace to util.

This commit is contained in:
Jim Posen
2018-09-01 15:18:02 -07:00
parent f3f9c1de19
commit 62e7addb63
5 changed files with 23 additions and 27 deletions

View File

@@ -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.
*