.. _program_listing_file_disk_io.hpp: Program Listing for File disk_io.hpp ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``disk_io.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef FELIX_DISKIO_H_ #define FELIX_DISKIO_H_ #include #include std::string errno_msg(int errn); class DiskIO { public: static constexpr std::string_view FREAD = "r"; static constexpr std::string_view FWRITE = "w+"; DiskIO(const std::string& filename, size_t block_size, std::string_view op, bool is_fifo); DiskIO(const DiskIO &) = delete; DiskIO &operator=(const DiskIO &) = delete; ~DiskIO(); size_t block_read(void *to_read, size_t max_blocks); size_t block_write(const void *to_write, size_t max_blocks); size_t byte_read(void* to_read, size_t bytes); size_t byte_write(void* to_write, size_t bytes); bool is_eof(); int reset_position(); private: std::string m_filename{}; size_t m_block_size{0}; int m_fd{-1}; FILE* m_fstream{nullptr}; void open_file(std::string_view op); void open_fifo(std::string_view op); }; #endif /* FELIX_DISKIO_H_ */