blob: bcb774a2906884865a8916fd163dcbe9cc0983ee [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&& /*in*/) noexcept;
FileHandle& operator=(FileHandle&& /*in*/) 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() const;
};