Class FileHandle

Class Documentation

class gkfs::data::FileHandle

File handle class to encapsulate a file descriptor, allowing RAII closing of the file descriptor.

Public Functions

FileHandle() = default
inline explicit FileHandle(int fd, const std::string &path) noexcept
FileHandle(FileHandle &&rhs) = default
FileHandle(const FileHandle &other) = delete
FileHandle &operator=(FileHandle &&rhs) = default
FileHandle &operator=(const FileHandle &other) = delete
inline explicit operator bool() const noexcept
inline bool operator!() const noexcept
inline bool valid() const noexcept

Checks for valid file descriptor value.

Returns

boolean if valid file descriptor

inline int native() const noexcept

Retusn the file descriptor value used in this file handle operation.

Returns

file descriptor value

inline bool close() noexcept

Closes file descriptor and resets it to initial value.

Returns

boolean if file descriptor was successfully closed

inline ~FileHandle()

Destructor implicitly closes the internal file descriptor.

Private Members

int fd_ = {init_value}

file descriptor

std::string path_ = {}

chunk file path

Private Static Attributes

static constexpr const int init_value = {-1}

initial file descriptor