mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
[util] GetFileSize
This commit is contained in:
parent
6ab3aad9a5
commit
86e22d23bb
2 changed files with 14 additions and 0 deletions
|
|
@ -141,6 +141,12 @@ bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes)
|
||||||
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.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,14 @@ void UnlockDirectory(const fs::path& directory, const std::string& lockfile_name
|
||||||
bool DirIsWritable(const fs::path& directory);
|
bool DirIsWritable(const fs::path& directory);
|
||||||
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
|
bool CheckDiskSpace(const fs::path& dir, uint64_t additional_bytes = 0);
|
||||||
|
|
||||||
|
/** Get the size of a file by scanning it.
|
||||||
|
*
|
||||||
|
* @param[in] path The file path
|
||||||
|
* @param[in] max Stop seeking beyond this limit
|
||||||
|
* @return The file size or max
|
||||||
|
*/
|
||||||
|
std::streampos GetFileSize(const char* path, std::streamsize max = std::numeric_limits<std::streamsize>::max());
|
||||||
|
|
||||||
/** Release all directory locks. This is used for unit testing only, at runtime
|
/** Release all directory locks. This is used for unit testing only, at runtime
|
||||||
* the global destructor will take care of the locks.
|
* the global destructor will take care of the locks.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue