Go to the documentation of this file.    1 #ifndef STORAGE_FSFILE_H 
    2 #define STORAGE_FSFILE_H 
   28     static FSFile *
Open(
const std::string& path, 
bool o_trunc,
 
   29                         bool o_direct, 
bool o_creat,
 
   78     void Read(
void *buf, 
size_t count, off_t offset);
 
   88     void Write(
const void *buf, 
size_t count, off_t offset);
 
  105     size_t Size() 
const noexcept;
 
  114     FSFile(
const std::string &path, 
int fd, 
size_t flen, 
bool o_direct):
 
  128     void ReadImpl(
void *buf, 
size_t count, off_t offset);
 
  138     void WriteImpl(
const void *buf, 
size_t count, off_t offset);
 
  157 #endif      // STORAGE_FSFILE_H 
 
void WriteImpl(const void *buf, size_t count, off_t offset)
Writes count bytes from the buffer buf into the file at the offset.
Definition: FSFile.cpp:190
 
Represents an open file in the file system.
Definition: FSFile.h:11
 
void Close()
Closes the file if it is still open.
Definition: FSFile.cpp:74
 
size_t Size() const noexcept
Returns the size of the file.
Definition: FSFile.cpp:153
 
int m_fd
Definition: FSFile.h:142
 
void ReadImpl(void *buf, size_t count, off_t offset)
Reads count bytes from the file at the offset into the buffer buf.
Definition: FSFile.cpp:166
 
~FSFile()
Desctructs the FSFile.
Definition: FSFile.cpp:44
 
static FSFile * Open(const std::string &path, bool o_trunc, bool o_direct, bool o_creat, mode_t mode=0600)
Opens or creates a file in the file system for read and write.
Definition: FSFile.cpp:14
 
bool m_o_direct
Definition: FSFile.h:141
 
FSFile(const std::string &path, int fd, size_t flen, bool o_direct)
Definition: FSFile.h:114
 
std::string m_path
Definition: FSFile.h:140
 
void Read(void *buf, size_t count, off_t offset)
Reads count bytes from the file at the offset into the buffer buf.
Definition: FSFile.cpp:98
 
bool IsOpen() const
Returns whether this file is open.
Definition: FSFile.cpp:85
 
void Allocate(size_t count)
Allocates count bytes at the end of the file and zeros those bytes.
Definition: FSFile.cpp:120
 
void Flush()
Flushes the data written to the disk.
Definition: FSFile.cpp:158
 
void Write(const void *buf, size_t count, off_t offset)
Writes count bytes from the buffer buf into the file at the offset.
Definition: FSFile.cpp:109
 
atomic_size_t m_flen
Definition: FSFile.h:143
 
void Delete() const
Deletes the file from the file system.
Definition: FSFile.cpp:90
 
bool fallocate_zerofill_fast(int fd, off_t offset, off_t len)
Calls fallocate(2) with mode FALLOC_FL_ZERO_RANGE if it is available.
Definition: FSFile_private.cpp:27
 
bool Reopen()
Opens the file again.
Definition: FSFile.cpp:49