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