mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 09:15:04 +02:00
util: Move CheckDiskSpace to util.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -72,6 +72,7 @@ bool RenameOver(fs::path src, fs::path dest);
|
||||
bool LockDirectory(const fs::path& directory, const std::string lockfile_name, bool probe_only=false);
|
||||
void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name);
|
||||
bool DirIsWritable(const fs::path& directory);
|
||||
bool CheckDiskSpace(const fs::path& dir, uint64_t nAdditionalBytes = 0);
|
||||
|
||||
/** Release all directory locks. This is used for unit testing only, at runtime
|
||||
* the global destructor will take care of the locks.
|
||||
|
||||
Reference in New Issue
Block a user