|
Tkrzw
|
Interface of file operations. More...
#include <tkrzw_file.h>
Public Types | |
| enum | OpenOption : int32_t { OPEN_DEFAULT = 0, OPEN_TRUNCATE = 1 << 0, OPEN_NO_CREATE = 1 << 1, OPEN_NO_WAIT = 1 << 2, OPEN_NO_LOCK = 1 << 3 } |
| Enumeration of options for Open. More... | |
Public Member Functions | |
| virtual | ~File ()=default |
| Destructor. More... | |
| virtual Status | Open (const std::string &path, bool writable, int32_t options=OPEN_DEFAULT)=0 |
| Opens a file. More... | |
| virtual Status | Close ()=0 |
| Closes the file. More... | |
| virtual Status | Read (int64_t off, void *buf, size_t size)=0 |
| Reads data. More... | |
| virtual std::string | ReadSimple (int64_t off, size_t size) |
| Reads data, in a simple way. More... | |
| virtual Status | Write (int64_t off, const void *buf, size_t size)=0 |
| Writes data. More... | |
| virtual bool | WriteSimple (int64_t off, std::string_view data) |
| Writes data, in a simple way. More... | |
| virtual Status | Append (const void *buf, size_t size, int64_t *off=nullptr)=0 |
| Appends data at the end of the file. More... | |
| virtual int64_t | AppendSimple (const std::string &data) |
| Appends data at the end of the file, in a simple way. More... | |
| virtual Status | Expand (size_t inc_size, int64_t *old_size=nullptr)=0 |
| Expands the file size without writing data. More... | |
| virtual int64_t | ExpandSimple (size_t inc_size) |
| Expands the file size without writing data, in a simple way. More... | |
| virtual Status | Truncate (int64_t size)=0 |
| Truncates the file. More... | |
| virtual Status | TruncateFakely (int64_t size)=0 |
| Truncate the file fakely. More... | |
| virtual Status | Synchronize (bool hard)=0 |
| Synchronizes the content of the file to the file system. More... | |
| virtual Status | GetSize (int64_t *size)=0 |
| Gets the size of the file. More... | |
| virtual int64_t | GetSizeSimple () |
| Gets the size of the file, in a simple way. More... | |
| virtual Status | SetAllocationStrategy (int64_t init_size, double inc_factor)=0 |
| Sets allocation strategy. More... | |
| virtual Status | CopyProperties (File *file)=0 |
| Copies internal properties to another file object. More... | |
| virtual Status | GetPath (std::string *path)=0 |
| Gets the path of the file. More... | |
| virtual std::string | GetPathSimple () |
| Gets the path of the file, in a simple way. More... | |
| virtual Status | Rename (const std::string &new_path)=0 |
| Renames the file. More... | |
| virtual Status | DisablePathOperations ()=0 |
| Disables operations related to the path. More... | |
| virtual bool | IsMemoryMapping () const =0 |
| Checks whether operations are done by memory mapping. More... | |
| virtual bool | IsAtomic () const =0 |
| Checks whether updating operations are atomic and thread-safe. More... | |
| virtual std::unique_ptr< File > | MakeFile () const =0 |
| Makes a new file object of the same concrete class. More... | |
Static Public Attributes | |
| static constexpr int64_t | DEFAULT_ALLOC_INIT_SIZE = 1LL << 20 |
| The default value of the initial allocation size. More... | |
| static constexpr double | DEFAULT_ALLOC_INC_FACTOR = 2.0 |
| The default value of the allocation increment factor. More... | |
Interface of file operations.
| enum tkrzw::File::OpenOption : int32_t |
|
virtualdefault |
Destructor.
|
pure virtual |
Opens a file.
| path | A path of the file. |
| writable | If true, the file is writable. If false, it is read-only. |
| options | Bit-sum options of File::OpenOption enums. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Closes the file.
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Reads data.
| off | The offset of a source region. |
| buf | The pointer to the destination buffer. |
| size | The size of the data to be read. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Reads data, in a simple way.
| off | The offset of a source region. |
| size | The size of the data to be read. |
Reimplemented in tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Writes data.
| off | The offset of the destination region. |
| buf | The pointer to the source buffer. |
| size | The size of the data to be written. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Writes data, in a simple way.
| off | The offset of the destination region. |
| data | The data to be written. |
|
pure virtual |
Appends data at the end of the file.
| buf | The pointer to the source buffer. |
| size | The size of the data to be written. |
| off | The pointer to an integer object to contain the offset at which the data has been put. If it is nullptr, it is ignored. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Appends data at the end of the file, in a simple way.
| data | The data to be written. |
|
pure virtual |
Expands the file size without writing data.
| inc_size | The size to increment the file size by. |
| old_size | The pointer to an integer object to contain the old size of the file. put. If it is nullptr, it is ignored. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Expands the file size without writing data, in a simple way.
| inc_size | The size to increment the file size by. |
|
pure virtual |
Truncates the file.
| size | The new size of the file. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Truncate the file fakely.
| size | The new size of the file. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Synchronizes the content of the file to the file system.
| hard | True to do physical synchronization with the hardware or false to do only logical synchronization with the file system. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Gets the size of the file.
| size | The pointer to an integer object to contain the result size. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Gets the size of the file, in a simple way.
|
pure virtual |
Sets allocation strategy.
| init_size | An initial size of allocation. |
| inc_factor | A factor to increase the size of allocation. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
Copies internal properties to another file object.
| file | The other file object. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Gets the path of the file.
| path | The pointer to a string object to store the path. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
virtual |
Gets the path of the file, in a simple way.
|
pure virtual |
Renames the file.
| new_path | A new path of the file. |
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Disables operations related to the path.
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Checks whether operations are done by memory mapping.
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Checks whether updating operations are atomic and thread-safe.
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
pure virtual |
Makes a new file object of the same concrete class.
Implemented in tkrzw::StdFile, tkrzw::PositionalAtomicFile, tkrzw::PositionalParallelFile, tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.
|
staticconstexpr |
The default value of the initial allocation size.
|
staticconstexpr |
The default value of the allocation increment factor.