2021-12-12 00:42:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex/providers/provider.hpp>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#if defined(OS_WINDOWS)
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace hex::plugin::builtin::prv {
|
|
|
|
|
|
|
|
class DiskProvider : public hex::prv::Provider {
|
|
|
|
public:
|
|
|
|
DiskProvider();
|
|
|
|
~DiskProvider() override;
|
|
|
|
|
|
|
|
[[nodiscard]] bool isAvailable() const override;
|
|
|
|
[[nodiscard]] bool isReadable() const override;
|
|
|
|
[[nodiscard]] bool isWritable() const override;
|
|
|
|
[[nodiscard]] bool isResizable() const override;
|
|
|
|
[[nodiscard]] bool isSavable() const override;
|
|
|
|
|
|
|
|
void readRaw(u64 offset, void *buffer, size_t size) override;
|
|
|
|
void writeRaw(u64 offset, const void *buffer, size_t size) override;
|
|
|
|
[[nodiscard]] size_t getActualSize() const override;
|
|
|
|
|
2022-01-16 01:51:31 +01:00
|
|
|
void setPath(const fs::path &path);
|
2021-12-12 00:42:12 +01:00
|
|
|
|
|
|
|
[[nodiscard]] bool open() override;
|
|
|
|
void close() override;
|
|
|
|
|
2022-01-16 01:51:31 +01:00
|
|
|
[[nodiscard]] std::string getName() const override;
|
|
|
|
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
|
2021-12-12 00:42:12 +01:00
|
|
|
|
|
|
|
[[nodiscard]] bool hasLoadInterface() const override { return true; }
|
|
|
|
void drawLoadInterface() override;
|
2021-12-12 11:56:26 +01:00
|
|
|
|
2021-12-12 00:42:12 +01:00
|
|
|
protected:
|
2021-12-12 11:56:26 +01:00
|
|
|
void reloadDrives();
|
|
|
|
|
2021-12-12 00:42:12 +01:00
|
|
|
std::set<std::string> m_availableDrives;
|
2022-01-16 01:51:31 +01:00
|
|
|
fs::path m_path;
|
2021-12-12 00:42:12 +01:00
|
|
|
|
|
|
|
#if defined(OS_WINDOWS)
|
|
|
|
HANDLE m_diskHandle = INVALID_HANDLE_VALUE;
|
|
|
|
#else
|
2022-01-16 02:29:19 +01:00
|
|
|
std::string m_pathBuffer;
|
2021-12-12 00:42:12 +01:00
|
|
|
int m_diskHandle = -1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
size_t m_diskSize;
|
|
|
|
size_t m_sectorSize;
|
|
|
|
|
|
|
|
u64 m_sectorBufferAddress;
|
|
|
|
std::vector<u8> m_sectorBuffer;
|
|
|
|
|
|
|
|
bool m_readable = false;
|
|
|
|
bool m_writable = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|