19#include <vrs/os/CompilerAttributes.h>
21#include "FileHandler.h"
50 static unique_ptr<WriteFileHandler>
make(
const string& fileHandlerName);
56 return spec.chunks.empty() ? INVALID_FILE_SPEC :
create(spec.chunks.front(), spec.extras);
63 virtual int create(
const string& newFilePath,
const map<string, string>& options = {}) = 0;
71 if (spec.chunks.size() == 1) {
72 return create(spec.chunks.front() +
"_1", spec.extras);
74 return create(initialFilePath, spec.extras);
102 virtual int write(
const void* buffer,
size_t length) = 0;
104 template <typename T, std::enable_if_t<std::is_trivially_copyable<T>::value,
int> = 0>
106 return write(&
object,
sizeof(
object));
114 virtual int overwrite(
const void* buffer,
size_t length) = 0;
116 template <typename T, std::enable_if_t<std::is_trivially_copyable<T>::value,
int> = 0>
118 return overwrite(&
object,
sizeof(
object));
Class to abstract VRS file system operations, to enable support for alternate storage methods,...
Definition FileHandler.h:71
The WriteFileHandler interface adds write operations to the FileHandler interface.
Definition WriteFileHandler.h:45
int write(const T &object)
Helper for trivially copyable objects.
Definition WriteFileHandler.h:105
virtual void addSplitHead(MAYBE_UNUSED FileSpec &inOutSpec)
Definition WriteFileHandler.h:82
virtual bool reopenForUpdatesSupported() const =0
virtual int overwrite(const void *buffer, size_t length)=0
int overwrite(const T &object)
Helper for trivially copyable objects.
Definition WriteFileHandler.h:117
bool isReadOnly() const override=0
virtual int reopenForUpdates()=0
virtual int write(const void *buffer, size_t length)=0
virtual int create(const string &newFilePath, const map< string, string > &options={})=0
static unique_ptr< WriteFileHandler > make(const string &fileHandlerName)
Create a new WriteFileHandler from a name.
Definition FileHandlerFactory.cpp:213
virtual int create(const FileSpec &spec)
Definition WriteFileHandler.h:55
virtual bool getCurrentChunk(string &outChunkPath, size_t &outChunkIndex) const =0
Get the path of the current chunk, or an empty string if no chunk is open.
virtual int createSplitFile(const FileSpec &spec, const string &initialFilePath)
Definition WriteFileHandler.h:69
Definition AsyncDiskFileChunk.hpp:49
Generalized file descriptor class, allowing the efficient representation of complex file objects,...
Definition FileSpec.h:37