Skip to content
API Documentation
BastionGuard™
disk_reader.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <cstdint>
5#include <string>
6#include <vector>
7
8class DiskReader {
9public:
10 DiskReader();
12
13 bool open_readonly(const std::string& path, std::string& error);
14 void close();
15
16 bool is_open() const;
17 bool is_block_device() const;
18 uint64_t size() const;
19 uint32_t logical_sector_size() const;
20 const std::string& path() const;
21
22 bool read_at(uint64_t offset, void* buffer, size_t len);
23 std::vector<std::byte> read_block(uint64_t offset, size_t len);
24
25private:
26 int fd_;
28 uint64_t size_;
30 std::string path_;
31};
bool is_block_device_
bool is_block_device() const
bool is_open() const
std::vector< std::byte > read_block(uint64_t offset, size_t len)
uint32_t logical_sector_size() const
const std::string & path() const
bool read_at(uint64_t offset, void *buffer, size_t len)
bool open_readonly(const std::string &path, std::string &error)
uint64_t size_
uint32_t logical_sector_size_
uint64_t size() const
std::string path_