2020-11-11 09:18:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "providers/provider.hpp"
|
|
|
|
|
|
|
|
#include <string_view>
|
|
|
|
|
2020-11-16 00:23:27 +01:00
|
|
|
#include <sys/stat.h>
|
|
|
|
|
2020-11-11 09:18:35 +01:00
|
|
|
namespace hex::prv {
|
|
|
|
|
|
|
|
class FileProvider : public Provider {
|
|
|
|
public:
|
2020-11-11 10:47:02 +01:00
|
|
|
explicit FileProvider(std::string_view path);
|
|
|
|
~FileProvider() override;
|
2020-11-11 09:18:35 +01:00
|
|
|
|
2020-11-11 10:47:02 +01:00
|
|
|
bool isAvailable() override;
|
|
|
|
bool isReadable() override;
|
|
|
|
bool isWritable() override;
|
2020-11-11 09:18:35 +01:00
|
|
|
|
2020-11-11 10:47:02 +01:00
|
|
|
void read(u64 offset, void *buffer, size_t size) override;
|
2020-11-27 13:44:52 +01:00
|
|
|
void write(u64 offset, const void *buffer, size_t size) override;
|
2020-11-27 09:09:48 +01:00
|
|
|
|
|
|
|
void readRaw(u64 offset, void *buffer, size_t size) override;
|
2020-11-27 13:44:52 +01:00
|
|
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
2020-11-22 19:43:35 +01:00
|
|
|
size_t getActualSize() override;
|
2020-11-11 09:18:35 +01:00
|
|
|
|
2020-11-15 16:06:10 +01:00
|
|
|
std::vector<std::pair<std::string, std::string>> getDataInformation() override;
|
|
|
|
|
2020-11-11 09:18:35 +01:00
|
|
|
private:
|
|
|
|
FILE *m_file;
|
2020-11-15 16:06:10 +01:00
|
|
|
std::string m_path;
|
|
|
|
|
|
|
|
bool m_fileStatsValid = false;
|
|
|
|
struct stat m_fileStats = { 0 };
|
2020-11-11 09:18:35 +01:00
|
|
|
|
|
|
|
bool m_readable, m_writable;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|