1#ifndef joedb_Abstract_File_declared
2#define joedb_Abstract_File_declared
58 virtual size_t pread(
char *data,
size_t size, int64_t offset)
const {
return 0;}
61 virtual void pwrite(
const char *data,
size_t size, int64_t offset) {}
76 virtual void unlock(int64_t start, int64_t size)
noexcept {}
Head_Exclusive_Lock(Abstract_File &file)
Head_Shared_Lock(Abstract_File &file)
static constexpr int64_t last_position
virtual void copy_to(Abstract_File &destination, int64_t start, int64_t size) const
virtual void shared_lock(int64_t start, int64_t size)
Lock a range of bytes for reading (prevents writes, not reads)
virtual int64_t get_size() const
Get the size of the file, or -1 if it is unknown.
void exclusive_lock_head()
Abstract_File(Open_Mode mode)
Open_Mode get_mode() const noexcept
void copy_to(Abstract_File &destination) const
virtual void datasync()
Write data durably (no file-size change)
virtual void unlock(int64_t start, int64_t size) noexcept
Remove a lock. The range should match the range of a corresponding lock.
bool is_readonly() const noexcept
static void reading_past_end_of_file()
bool tail_is_locked() const noexcept
virtual void sync()
Write data durably (including file-size change)
virtual ~Abstract_File()=default
void unlock_head() noexcept
std::string read_blob(Blob blob) const
bool is_shared() const noexcept
void exclusive_lock_tail()
void unlock_tail() noexcept
virtual void pwrite(const char *data, size_t size, int64_t offset)
Write a range of bytes. Extend file size if necessary.
virtual bool equal_to(const Abstract_File &destination, int64_t from, int64_t until) const
virtual void exclusive_lock(int64_t start, int64_t size)
Lock a range of bytes for writing (prevents both writes and reads)
virtual size_t pread(char *data, size_t size, int64_t offset) const
Read a range of bytes.
@ write_existing
fails if does not exist or locked, locks the file for writing
@ shared_write
like write_existing_or_create_new, but does not lock the file, and does not fail if locked
@ read_existing
fails if does not exist