Changeset View
Changeset View
Standalone View
Standalone View
src/util.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | bool DirIsWritable(const fs::path &directory) { | ||||
} | } | ||||
fclose(file); | fclose(file); | ||||
remove(tmpFile); | remove(tmpFile); | ||||
return true; | return true; | ||||
} | } | ||||
bool CheckDiskSpace(const fs::path &dir, uint64_t nAdditionalBytes) { | |||||
// 50 MiB | |||||
constexpr uint64_t nMinDiskSpace = 52428800; | |||||
uint64_t nFreeBytesAvailable = fs::space(dir).available; | |||||
return nFreeBytesAvailable >= nMinDiskSpace + nAdditionalBytes; | |||||
} | |||||
/** | /** | ||||
* Interpret a string argument as a boolean. | * Interpret a string argument as a boolean. | ||||
* | * | ||||
* The definition of atoi() requires that non-numeric string values like "foo", | * The definition of atoi() requires that non-numeric string values like "foo", | ||||
* return 0. This means that if a user unintentionally supplies a non-integer | * return 0. This means that if a user unintentionally supplies a non-integer | ||||
* argument here, the return value is always false. This means that -foo=false | * argument here, the return value is always false. This means that -foo=false | ||||
* does what the user probably expects, but -foo=true is well defined but does | * does what the user probably expects, but -foo=true is well defined but does | ||||
* not do what they probably expected. | * not do what they probably expected. | ||||
▲ Show 20 Lines • Show All 966 Lines • Show Last 20 Lines |