20 throw std::invalid_argument(
"chunk_size must be positive");
40 fs::create_directories(path.parent_path());
50 if (fclose(file) != 0) {
74 if (fclose(file) != 0) {
96 if (fclose(file) != 0) {
103 if (fclose(file) != 0) {
110 if (fclose(file) != 0) {
FILE * Open(const FlatFilePos &pos, bool read_only=false) const
Open a handle to the file at the given position.
fs::path FileName(const FlatFilePos &pos) const
Get the name of the file at the given position.
bool Flush(const FlatFilePos &pos, bool finalize=false) const
Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final.
size_t Allocate(const FlatFilePos &pos, size_t add_size, bool &out_of_space) const
Allocate additional space in a file after the given starting position.
const size_t m_chunk_size
const char *const m_prefix
FlatFileSeq(fs::path dir, const char *prefix, size_t chunk_size)
Constructor.
static path u8path(std::string_view utf8_str)
static std::string PathToString(const path &path)
Convert path object to a byte string.
void DirectoryCommit(const fs::path &dirname)
Sync directory contents.
void AllocateFileRange(FILE *file, unsigned int offset, unsigned int length)
this function tries to make a particular range of a file allocated (corresponding to disk space) it i...
bool CheckDiskSpace(const fs::path &dir, uint64_t additional_bytes)
bool TruncateFile(FILE *file, unsigned int length)
bool FileCommit(FILE *file)
Ensure file contents are fully committed to disk, using a platform-specific feature analogous to fsyn...
#define LogDebug(category,...)
FILE * fopen(const fs::path &p, const char *mode)
std::string ToString() const
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.