Changeset View
Changeset View
Standalone View
Standalone View
src/util/system.cpp
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | |||||
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes) { | bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes) { | ||||
// 50 MiB | // 50 MiB | ||||
constexpr uint64_t min_disk_space = 52428800; | constexpr uint64_t min_disk_space = 52428800; | ||||
uint64_t free_bytes_available = fs::space(dir).available; | uint64_t free_bytes_available = fs::space(dir).available; | ||||
return free_bytes_available >= min_disk_space + additional_bytes; | return free_bytes_available >= min_disk_space + additional_bytes; | ||||
} | } | ||||
std::streampos GetFileSize(const char *path, std::streamsize max) { | |||||
std::ifstream file(path, std::ios::binary); | |||||
file.ignore(max); | |||||
return file.gcount(); | |||||
} | |||||
/** | /** | ||||
* 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 1,228 Lines • Show Last 20 Lines |