blob: 46e55397518c5d70f2544994dc36294b1139ac68 [file] [log] [blame]
#pragma once
#include <filesystem>
#include <ios>
// An RAII compliant object for holding a posix file descriptor
class FileHandle
{
private:
int fd;
public:
FileHandle() = delete;
FileHandle(const FileHandle&) = delete;
FileHandle& operator=(const FileHandle&) = delete;
FileHandle(FileHandle&&) noexcept;
FileHandle& operator=(FileHandle&&) noexcept;
explicit FileHandle(const std::filesystem::path& name,
std::ios_base::openmode mode = std::ios_base::in |
std::ios_base::out);
explicit FileHandle(int fd);
~FileHandle();
int handle();
};