16 throw std::invalid_argument(
"chunk_size must be positive");
67 "Pre-allocating up to position 0x%x in %s%05u.dat\n",
fs::path FileName(const FlatFilePos &pos) const
Get the name of the file at the given position.
const size_t m_chunk_size
size_t Allocate(const FlatFilePos &pos, size_t add_size, bool &out_of_space)
Allocate additional space in a file after the given starting position.
bool Flush(const FlatFilePos &pos, bool finalize=false)
Commit a file to disk, and optionally truncate off extra pre-allocated bytes if final.
const char *const m_prefix
FlatFileSeq(fs::path dir, const char *prefix, size_t chunk_size)
Constructor.
FILE * Open(const FlatFilePos &pos, bool read_only=false)
Open a handle to the file at the given position.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
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...
bool error(const char *fmt, const Args &...args)
#define LogPrint(category,...)
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
static std::string PathToString(const path &path)
Convert path object to byte string.
FILE * fopen(const fs::path &p, const char *mode)
Implement std::hash so RCUPtr can be used as a key for maps or sets.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
std::string ToString() const