1
0
mirror of synced 2024-11-28 09:30:51 +01:00

sys: Bunch of cleanup, use fs::path instead of std::string for paths

This commit is contained in:
WerWolv 2022-01-16 01:51:31 +01:00
parent ed8ee35a86
commit a70ece7b9c
32 changed files with 206 additions and 292 deletions

View File

@ -16,7 +16,7 @@ namespace hex {
class Plugin {
public:
Plugin(const std::string &path);
Plugin(const fs::path &path);
Plugin(const Plugin&) = delete;
Plugin(Plugin &&other) noexcept;
~Plugin();

View File

@ -14,8 +14,8 @@ namespace hex {
constexpr auto GetPluginDescriptionSymbol = "_ZN3hex6plugin{0}{1}8internal20getPluginDescriptionEv";
constexpr auto SetImGuiContextSymbol = "_ZN3hex6plugin{0}{1}8internal15setImGuiContextEP12ImGuiContext";
Plugin::Plugin(const std::string &path) {
this->m_handle = dlopen(path.data(), RTLD_LAZY);
Plugin::Plugin(const fs::path &path) {
this->m_handle = dlopen(path.string().c_str(), RTLD_LAZY);
if (this->m_handle == nullptr) {
log::error("dlopen failed: {}", dlerror());

View File

@ -174,11 +174,11 @@ namespace hex {
}
});
EventManager::subscribe<EventFileLoaded>(this, [](const std::string &path){
EventManager::subscribe<EventFileLoaded>(this, [](const auto &path){
SharedData::recentFilePaths.push_front(path);
{
std::list<std::string> uniques;
std::list<fs::path> uniques;
for (auto &file : SharedData::recentFilePaths) {
bool exists = false;
@ -198,7 +198,8 @@ namespace hex {
{
std::vector<std::string> recentFilesVector;
std::copy(SharedData::recentFilePaths.begin(), SharedData::recentFilePaths.end(), std::back_inserter(recentFilesVector));
for (const auto &recentPath : SharedData::recentFilePaths)
recentFilesVector.push_back(recentPath.string());
ContentRegistry::Settings::write("hex.builtin.setting.imhex", "hex.builtin.setting.imhex.recent_files", recentFilesVector);
}

View File

@ -27,13 +27,13 @@ namespace hex::plugin::builtin::prv {
void writeRaw(u64 offset, const void *buffer, size_t size) override;
[[nodiscard]] size_t getActualSize() const override;
void setPath(const std::string &path);
void setPath(const fs::path &path);
[[nodiscard]] bool open() override;
void close() override;
[[nodiscard]] virtual std::string getName() const;
[[nodiscard]] virtual std::vector<std::pair<std::string, std::string>> getDataInformation() const;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
[[nodiscard]] bool hasLoadInterface() const override { return true; }
void drawLoadInterface() override;
@ -42,7 +42,7 @@ namespace hex::plugin::builtin::prv {
void reloadDrives();
std::set<std::string> m_availableDrives;
std::string m_path;
fs::path m_path;
#if defined(OS_WINDOWS)
HANDLE m_diskHandle = INVALID_HANDLE_VALUE;

View File

@ -36,12 +36,12 @@ namespace hex::plugin::builtin::prv {
[[nodiscard]] size_t getActualSize() const override;
void save() override;
void saveAs(const std::string &path) override;
void saveAs(const fs::path &path) override;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;
void setPath(const std::string &path);
void setPath(const fs::path &path);
[[nodiscard]] bool open() override;
void close() override;
@ -54,7 +54,7 @@ namespace hex::plugin::builtin::prv {
int m_file = -1;
#endif
std::string m_path;
fs::path m_path;
void *m_mappedFile = nullptr;
size_t m_fileSize = 0;

View File

@ -29,7 +29,7 @@ class GDBProvider : public hex::prv::Provider {
[[nodiscard]] size_t getActualSize() const override;
void save() override;
void saveAs(const std::string &path) override;
void saveAs(const fs::path &path) override;
[[nodiscard]] std::string getName() const override;
[[nodiscard]] std::vector<std::pair<std::string, std::string>> getDataInformation() const override;

View File

@ -60,12 +60,8 @@ namespace hex::plugin::builtin {
void drawGotoPopup();
void drawEditPopup();
bool createFile(const std::string &path);
void openFile(const std::string &path);
bool saveToFile(const std::string &path, const std::vector<u8>& data);
bool loadFromFile(const std::string &path, std::vector<u8>& data);
void openFile(const fs::path &path);
enum class Language { C, Cpp, CSharp, Rust, Python, Java, JavaScript };
void copyBytes() const;
void pasteBytes() const;
void copyString() const;

View File

@ -77,7 +77,7 @@ namespace hex::plugin::builtin {
void drawEnvVars(ImVec2 size);
void drawVariableSettings(ImVec2 size);
void loadPatternFile(const std::string &path);
void loadPatternFile(const fs::path &path);
void clearPatternData();
void parsePattern(const std::string &code);

View File

@ -54,7 +54,7 @@ namespace hex::plugin::builtin::prv {
}
void DiskProvider::setPath(const std::string &path) {
void DiskProvider::setPath(const fs::path &path) {
this->m_path = path;
}
@ -64,19 +64,11 @@ namespace hex::plugin::builtin::prv {
#if defined (OS_WINDOWS)
std::wstring widePath;
{
auto length = this->m_path.length() + 1;
auto wideLength = MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, 0, 0);
auto buffer = new wchar_t[wideLength];
MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, buffer, wideLength);
widePath = buffer;
delete[] buffer;
}
const auto &path = this->m_path.native();
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(widePath.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (this->m_diskHandle == INVALID_HANDLE_VALUE) {
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(widePath.data(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_diskHandle = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_writable = false;
if (this->m_diskHandle == INVALID_HANDLE_VALUE)
@ -245,12 +237,12 @@ namespace hex::plugin::builtin::prv {
}
std::string DiskProvider::getName() const {
return this->m_path;
return this->m_path.string();
}
std::vector<std::pair<std::string, std::string>> DiskProvider::getDataInformation() const {
return {
{ "hex.builtin.provider.disk.selected_disk"_lang, this->m_path },
{ "hex.builtin.provider.disk.selected_disk"_lang, this->m_path.string() },
{ "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(this->m_diskSize) },
{ "hex.builtin.provider.disk.sector_size"_lang, hex::toByteString(this->m_sectorSize) }
};

View File

@ -82,7 +82,7 @@ namespace hex::plugin::builtin::prv {
this->applyPatches();
}
void FileProvider::saveAs(const std::string &path) {
void FileProvider::saveAs(const fs::path &path) {
File file(path, File::Mode::Create);
if (file.isValid()) {
@ -104,32 +104,10 @@ namespace hex::plugin::builtin::prv {
void FileProvider::resize(ssize_t newSize) {
this->close();
#if defined(OS_WINDOWS)
std::wstring widePath;
{
auto length = static_cast<int>(this->m_path.length() + 1);
auto wideLength = MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, nullptr, 0);
auto buffer = new wchar_t[wideLength];
MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, buffer, wideLength);
widePath = buffer;
delete[] buffer;
File(this->m_path, File::Mode::Write).setSize(newSize);
}
auto handle = ::CreateFileW(widePath.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle != INVALID_HANDLE_VALUE) {
::SetFilePointerEx(handle, LARGE_INTEGER { .QuadPart = newSize }, nullptr, FILE_BEGIN);
::SetEndOfFile(handle);
::CloseHandle(handle);
}
#else
auto handle = ::open(this->m_path.data(), 0644);
::ftruncate(handle, newSize - 1);
::close(handle);
#endif
this->open();
}
@ -144,7 +122,7 @@ namespace hex::plugin::builtin::prv {
std::vector<std::pair<std::string, std::string>> FileProvider::getDataInformation() const {
std::vector<std::pair<std::string, std::string>> result;
result.emplace_back("hex.builtin.provider.file.path"_lang, this->m_path);
result.emplace_back("hex.builtin.provider.file.path"_lang, this->m_path.string());
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
if (this->m_fileStatsValid) {
@ -156,90 +134,82 @@ namespace hex::plugin::builtin::prv {
return result;
}
void FileProvider::setPath(const std::string &path) {
void FileProvider::setPath(const fs::path &path) {
this->m_path = path;
}
bool FileProvider::open() {
this->m_fileStatsValid = stat(this->m_path.data(), &this->m_fileStats) == 0;
this->m_fileStatsValid = stat(this->m_path.string().data(), &this->m_fileStats) == 0;
this->m_readable = true;
this->m_writable = true;
#if defined(OS_WINDOWS)
std::wstring widePath;
{
auto length = this->m_path.length() + 1;
auto wideLength = MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, 0, 0);
auto buffer = new wchar_t[wideLength];
MultiByteToWideChar(CP_UTF8, 0, this->m_path.data(), length, buffer, wideLength);
widePath = buffer;
delete[] buffer;
}
const auto &path = this->m_path.native();
LARGE_INTEGER fileSize = { 0 };
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(widePath.data(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
LARGE_INTEGER fileSize = { 0 };
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
GetFileSizeEx(this->m_file, &fileSize);
this->m_fileSize = fileSize.QuadPart;
CloseHandle(this->m_file);
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(widePath.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(widePath.data(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_writable = false;
}
auto fileCleanup = SCOPE_GUARD {
GetFileSizeEx(this->m_file, &fileSize);
this->m_fileSize = fileSize.QuadPart;
CloseHandle(this->m_file);
this->m_readable = false;
this->m_file = nullptr;
};
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
return false;
}
if (this->m_fileSize > 0) {
this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READWRITE, 0, 0, nullptr);
if (this->m_mapping == nullptr || this->m_mapping == INVALID_HANDLE_VALUE) {
this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READONLY, 0, 0, nullptr);
if (this->m_mapping == nullptr || this->m_mapping == INVALID_HANDLE_VALUE)
return false;
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
this->m_file = reinterpret_cast<HANDLE>(CreateFileW(path.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr));
this->m_writable = false;
}
auto mappingCleanup = SCOPE_GUARD {
CloseHandle(this->m_mapping);
auto fileCleanup = SCOPE_GUARD {
CloseHandle(this->m_file);
this->m_mapping = nullptr;
this->m_readable = false;
this->m_file = nullptr;
};
this->m_mappedFile = MapViewOfFile(this->m_mapping, FILE_MAP_ALL_ACCESS, 0, 0, this->m_fileSize);
if (this->m_mappedFile == nullptr) {
this->m_mappedFile = MapViewOfFile(this->m_mapping, FILE_MAP_READ, 0, 0, this->m_fileSize);
if (this->m_mappedFile == nullptr) {
this->m_readable = false;
return false;
}
if (this->m_file == nullptr || this->m_file == INVALID_HANDLE_VALUE) {
return false;
}
mappingCleanup.release();
if (this->m_fileSize > 0) {
this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READWRITE, 0, 0, nullptr);
if (this->m_mapping == nullptr || this->m_mapping == INVALID_HANDLE_VALUE) {
ProjectFile::setFilePath(this->m_path);
} else if (!this->m_emptyFile) {
this->m_emptyFile = true;
this->resize(1);
} else {
return false;
}
this->m_mapping = CreateFileMapping(this->m_file, nullptr, PAGE_READONLY, 0, 0, nullptr);
fileCleanup.release();
if (this->m_mapping == nullptr || this->m_mapping == INVALID_HANDLE_VALUE)
return false;
}
auto mappingCleanup = SCOPE_GUARD {
CloseHandle(this->m_mapping);
this->m_mapping = nullptr;
this->m_readable = false;
};
this->m_mappedFile = MapViewOfFile(this->m_mapping, FILE_MAP_ALL_ACCESS, 0, 0, this->m_fileSize);
if (this->m_mappedFile == nullptr) {
this->m_mappedFile = MapViewOfFile(this->m_mapping, FILE_MAP_READ, 0, 0, this->m_fileSize);
if (this->m_mappedFile == nullptr) {
this->m_readable = false;
return false;
}
}
mappingCleanup.release();
ProjectFile::setFilePath(this->m_path);
} else if (!this->m_emptyFile) {
this->m_emptyFile = true;
this->resize(1);
} else {
return false;
}
fileCleanup.release();
#else
this->m_file = ::open(this->m_path.data(), O_RDWR);

View File

@ -214,7 +214,7 @@ namespace hex::plugin::builtin::prv {
this->applyPatches();
}
void GDBProvider::saveAs(const std::string &path) {
void GDBProvider::saveAs(const fs::path &path) {
}

View File

@ -682,8 +682,8 @@ namespace hex::plugin::builtin {
ImGui::InputText("##path", selectedFile.data(), selectedFile.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &selectedFile);
ImGui::SameLine();
if (ImGui::Button("...")) {
hex::openFileBrowser("hex.builtin.tools.file_tools.shredder.picker"_lang, DialogMode::Open, {}, [](const std::string &path) {
selectedFile = path;
hex::openFileBrowser("hex.builtin.tools.file_tools.shredder.picker"_lang, DialogMode::Open, {}, [](const auto &path) {
selectedFile = path.string();
});
}
@ -798,8 +798,8 @@ namespace hex::plugin::builtin {
ImGui::InputText("##path", selectedFile.data(), selectedFile.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &selectedFile);
ImGui::SameLine();
if (ImGui::Button("...##input")) {
hex::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.input"_lang, DialogMode::Open, {}, [](const std::string &path) {
selectedFile = path;
hex::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.input"_lang, DialogMode::Open, {}, [](const auto &path) {
selectedFile = path.string();
});
}
ImGui::SameLine();
@ -808,8 +808,8 @@ namespace hex::plugin::builtin {
ImGui::InputText("##base_path", baseOutputPath.data(), baseOutputPath.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &baseOutputPath);
ImGui::SameLine();
if (ImGui::Button("...##output")) {
hex::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.output"_lang, DialogMode::Save, {}, [](const std::string &path) {
baseOutputPath = path;
hex::openFileBrowser("hex.builtin.tools.file_tools.splitter.picker.output"_lang, DialogMode::Save, {}, [](const auto &path) {
baseOutputPath = path.string();
});
}
ImGui::SameLine();
@ -934,8 +934,8 @@ namespace hex::plugin::builtin {
ImGui::BeginDisabled(combining);
{
if (ImGui::Button("hex.builtin.tools.file_tools.combiner.add"_lang)) {
hex::openFileBrowser("hex.builtin.tools.file_tools.combiner.add.picker"_lang, DialogMode::Open, {}, [](const std::string &path) {
files.push_back(path);
hex::openFileBrowser("hex.builtin.tools.file_tools.combiner.add.picker"_lang, DialogMode::Open, {}, [](const auto &path) {
files.push_back(path.string());
});
}
ImGui::SameLine();
@ -958,8 +958,8 @@ namespace hex::plugin::builtin {
ImGui::InputText("##output_path", outputPath.data(), outputPath.capacity(), ImGuiInputTextFlags_CallbackEdit, ImGui::UpdateStringSizeCallback, &outputPath);
ImGui::SameLine();
if (ImGui::Button("...")) {
hex::openFileBrowser("hex.builtin.tools.file_tools.combiner.output.picker"_lang, DialogMode::Save, {}, [](const std::string &path) {
outputPath = path;
hex::openFileBrowser("hex.builtin.tools.file_tools.combiner.output.picker"_lang, DialogMode::Save, {}, [](const auto &path) {
outputPath = path.string();
});
}
ImGui::SameLine();

View File

@ -38,7 +38,7 @@ namespace hex::plugin::builtin {
}
});
EventManager::subscribe<EventFileLoaded>(this, [this](const std::string &path){
EventManager::subscribe<EventFileLoaded>(this, [this](const fs::path &path){
for (auto &node : this->m_nodes) {
node->setCurrentOverlay(nullptr);
}

View File

@ -17,19 +17,9 @@
#include <nlohmann/json.hpp>
#undef __STRICT_ANSI__
#include <cstdio>
#include <thread>
#include <filesystem>
#if defined(OS_WINDOWS)
#include <windows.h>
#else
#include <fcntl.h>
#include <unistd.h>
#endif
namespace hex::plugin::builtin {
ViewHexEditor::ViewHexEditor() : View("hex.builtin.view.hexeditor.name"_lang) {
@ -41,6 +31,12 @@ namespace hex::plugin::builtin {
return ProjectFile::load(path.string());
});
ContentRegistry::FileHandler::add({ ".tbl" }, [this](const auto &path) {
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
return true;
});
this->m_memoryEditor.ReadFn = [](const ImU8 *data, size_t off) -> ImU8 {
auto provider = ImHexApi::Provider::get();
if (!provider->isAvailable() || !provider->isReadable())
@ -233,7 +229,7 @@ namespace hex::plugin::builtin {
}
static void saveAs() {
hex::openFileBrowser("hex.builtin.view.hexeditor.save_as"_lang, DialogMode::Save, { }, [](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.save_as"_lang, DialogMode::Save, { }, [](const auto &path) {
ImHexApi::Provider::get()->saveAs(path);
});
}
@ -267,15 +263,15 @@ namespace hex::plugin::builtin {
ImGui::InputText("##nolabel", this->m_loaderScriptScriptPath.data(), this->m_loaderScriptScriptPath.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
if (ImGui::Button("hex.builtin.view.hexeditor.script.script"_lang)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.script.script.title"_lang, DialogMode::Open, { { "Python Script", "py" } }, [this](auto path) {
this->m_loaderScriptScriptPath = path;
hex::openFileBrowser("hex.builtin.view.hexeditor.script.script.title"_lang, DialogMode::Open, { { "Python Script", "py" } }, [this](const auto &path) {
this->m_loaderScriptScriptPath = path.string();
});
}
ImGui::InputText("##nolabel", this->m_loaderScriptFilePath.data(), this->m_loaderScriptFilePath.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::SameLine();
if (ImGui::Button("hex.builtin.view.hexeditor.script.file"_lang)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.script.file.title"_lang, DialogMode::Open, { }, [this](auto path) {
this->m_loaderScriptFilePath = path;
hex::openFileBrowser("hex.builtin.view.hexeditor.script.file.title"_lang, DialogMode::Open, { }, [this](const auto &path) {
this->m_loaderScriptFilePath = path.string();
});
}
if (ImGui::IsKeyDown(ImGui::GetKeyIndex(ImGuiKey_Escape)))
@ -346,7 +342,7 @@ namespace hex::plugin::builtin {
if (ImGui::BeginMenu("hex.menu.file"_lang)) {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_file"_lang, "CTRL + O")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [](const auto &path) {
EventManager::post<RequestOpenFile>(path);
});
}
@ -402,19 +398,19 @@ namespace hex::plugin::builtin {
ImGui::Separator();
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.open_project"_lang, "")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [](const auto &path) {
ProjectFile::load(path);
});
}
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.save_project"_lang, "", false, providerValid && provider->isWritable())) {
if (ProjectFile::getProjectFilePath() == "") {
hex::openFileBrowser("hex.builtin.view.hexeditor.save_project"_lang, DialogMode::Save, { { "Project File", "hexproj" } }, [](auto path) {
if (path.ends_with(".hexproj")) {
hex::openFileBrowser("hex.builtin.view.hexeditor.save_project"_lang, DialogMode::Save, { { "Project File", "hexproj" } }, [](const auto &path) {
if (path.extension() == ".hexproj") {
ProjectFile::store(path);
}
else {
ProjectFile::store(path + ".hexproj");
ProjectFile::store(path.string() + ".hexproj");
}
});
}
@ -423,7 +419,7 @@ namespace hex::plugin::builtin {
}
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.load_encoding_file"_lang)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.load_enconding_file"_lang, DialogMode::Open, { { "Thingy Table File", "tbl" } }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.load_enconding_file"_lang, DialogMode::Open, { { "Thingy Table File", "tbl" } }, [this](const auto &path) {
this->m_currEncodingFile = EncodingFile(EncodingFile::Type::Thingy, path);
});
}
@ -433,9 +429,14 @@ namespace hex::plugin::builtin {
if (ImGui::BeginMenu("hex.builtin.view.hexeditor.menu.file.import"_lang)) {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.base64"_lang)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.import.base64"_lang, DialogMode::Open, { }, [this](auto path) {
std::vector<u8> base64;
this->loadFromFile(path, base64);
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.import.base64"_lang, DialogMode::Open, { }, [this](const auto &path) {
File file(path, File::Mode::Read);
if (!file.isValid()) {
View::showErrorPopup("hex.builtin.view.hexeditor.error.open"_lang);
return;
}
auto base64 = file.readBytes();
if (!base64.empty()) {
this->m_dataToSave = crypt::decode64(base64);
@ -453,7 +454,7 @@ namespace hex::plugin::builtin {
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips"_lang, nullptr, false, !this->m_processingImportExport)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
this->m_processingImportExport = true;
std::thread([this, path] {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
@ -483,7 +484,7 @@ namespace hex::plugin::builtin {
}
if (ImGui::MenuItem("hex.builtin.view.hexeditor.menu.file.import.ips32"_lang, nullptr, false, !this->m_processingImportExport)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
this->m_processingImportExport = true;
std::thread([this, path] {
auto task = ImHexApi::Tasks::createTask("hex.builtin.view.hexeditor.processing", 0);
@ -536,8 +537,14 @@ namespace hex::plugin::builtin {
this->m_processingImportExport = false;
View::doLater([this]{
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](auto path) {
this->saveToFile(path, this->m_dataToSave);
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
auto file = File(path, File::Mode::Create);
if (!file.isValid()) {
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
return;
}
file.write(this->m_dataToSave);
});
});
}).detach();
@ -558,8 +565,14 @@ namespace hex::plugin::builtin {
this->m_processingImportExport = false;
View::doLater([this]{
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](auto path) {
this->saveToFile(path, this->m_dataToSave);
hex::openFileBrowser("hex.builtin.view.hexeditor.menu.file.export.title"_lang, DialogMode::Save, { }, [this](const auto &path) {
auto file = File(path, File::Mode::Create);
if (!file.isValid()) {
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
return;
}
file.write(this->m_dataToSave);
});
});
}).detach();
@ -591,41 +604,7 @@ namespace hex::plugin::builtin {
}
}
bool ViewHexEditor::createFile(const std::string &path) {
#if defined(OS_WINDOWS)
std::wstring widePath;
{
auto length = path.length() + 1;
auto wideLength = MultiByteToWideChar(CP_UTF8, 0, path.data(), length, 0, 0);
auto buffer = new wchar_t[wideLength];
MultiByteToWideChar(CP_UTF8, 0, path.data(), length, buffer, wideLength);
widePath = buffer;
delete[] buffer;
}
auto handle = ::CreateFileW(widePath.data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
if (handle == INVALID_HANDLE_VALUE)
return false;
::SetFilePointer(handle, 1, nullptr, FILE_BEGIN);
::SetEndOfFile(handle);
::CloseHandle(handle);
#else
auto handle = ::open(path.data(), O_RDWR | O_CREAT, 0644);
if (handle == -1)
return false;
lseek(handle, 0, SEEK_SET);
write(handle, "", 1);
close(handle);
#endif
return true;
}
void ViewHexEditor::openFile(const std::string &path) {
void ViewHexEditor::openFile(const fs::path &path) {
hex::prv::Provider *provider = nullptr;
EventManager::post<RequestCreateProvider>("hex.builtin.provider.file", &provider);
@ -666,18 +645,6 @@ namespace hex::plugin::builtin {
}
}
bool ViewHexEditor::saveToFile(const std::string &path, const std::vector<u8>& data) {
File(path, File::Mode::Create).write(data);
return true;
}
bool ViewHexEditor::loadFromFile(const std::string &path, std::vector<u8>& data) {
data = File(path, File::Mode::Read).readBytes();
return true;
}
void ViewHexEditor::copyBytes() const {
auto provider = ImHexApi::Provider::get();
@ -1046,8 +1013,8 @@ namespace hex::plugin::builtin {
}
void ViewHexEditor::registerEvents() {
EventManager::subscribe<RequestOpenFile>(this, [this](const std::string &filePath) {
this->openFile(filePath);
EventManager::subscribe<RequestOpenFile>(this, [this](const auto &path) {
this->openFile(path);
this->getWindowOpenState() = true;
});
@ -1080,22 +1047,26 @@ namespace hex::plugin::builtin {
EventManager::subscribe<RequestOpenWindow>(this, [this](std::string name) {
if (name == "Create File") {
hex::openFileBrowser("hex.builtin.view.hexeditor.create_file"_lang, DialogMode::Save, { }, [this](auto path) {
if (!this->createFile(path)) {
hex::openFileBrowser("hex.builtin.view.hexeditor.create_file"_lang, DialogMode::Save, { }, [this](const auto &path) {
File file(path, File::Mode::Create);
if (!file.isValid()) {
View::showErrorPopup("hex.builtin.view.hexeditor.error.create"_lang);
return;
}
file.setSize(1);
EventManager::post<RequestOpenFile>(path);
this->getWindowOpenState() = true;
});
} else if (name == "Open File") {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [this](const auto &path) {
EventManager::post<RequestOpenFile>(path);
this->getWindowOpenState() = true;
});
} else if (name == "Open Project") {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_project"_lang, DialogMode::Open, { { "Project File", "hexproj" } }, [this](const auto &path) {
ProjectFile::load(path);
this->getWindowOpenState() = true;
});
@ -1198,7 +1169,7 @@ namespace hex::plugin::builtin {
});
ShortcutManager::addShortcut(this, CTRL + Keys::O, [] {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [](auto path) {
hex::openFileBrowser("hex.builtin.view.hexeditor.open_file"_lang, DialogMode::Open, { }, [](const auto &path) {
EventManager::post<RequestOpenFile>(path);
});
});
@ -1216,7 +1187,7 @@ namespace hex::plugin::builtin {
this->pasteBytes();
});
ShortcutManager::addShortcut(this, CTRL + Keys::A, [this] {
ShortcutManager::addShortcut(this, CTRL + Keys::A, [] {
auto provider = ImHexApi::Provider::get();
EventManager::post<RequestSelectionChange>(Region { provider->getBaseAddress(), provider->getActualSize() });
});

View File

@ -110,7 +110,7 @@ namespace hex::plugin::builtin {
this->m_textEditor.InsertText(code);
});
EventManager::subscribe<EventFileLoaded>(this, [this](const std::string &path) {
EventManager::subscribe<EventFileLoaded>(this, [this](const fs::path &path) {
if (!ContentRegistry::Settings::read("hex.builtin.setting.general", "hex.builtin.setting.general.auto_load_patterns", 1))
return;
@ -232,7 +232,7 @@ namespace hex::plugin::builtin {
}
if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang)) {
hex::openFileBrowser("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, DialogMode::Save, { { "Pattern", "hexpat" }}, [this](const std::string &path) {
hex::openFileBrowser("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, DialogMode::Save, { { "Pattern", "hexpat" }}, [this](const auto &path) {
File file(path, File::Mode::Create);
file.write(this->m_textEditor.GetText());
@ -586,7 +586,7 @@ namespace hex::plugin::builtin {
ImGui::SameLine();
if (ImGui::Button("hex.common.browse"_lang)) {
hex::openFileBrowser("hex.builtin.view.pattern_editor.open_pattern"_lang, DialogMode::Open, { { "Pattern File", "hexpat" } }, [this](auto path) {
hex::openFileBrowser("hex.builtin.view.pattern_editor.open_pattern"_lang, DialogMode::Open, { { "Pattern File", "hexpat" } }, [this](const auto &path) {
this->loadPatternFile(path);
ImGui::CloseCurrentPopup();
});
@ -597,27 +597,13 @@ namespace hex::plugin::builtin {
}
void ViewPatternEditor::loadPatternFile(const std::string &path) {
FILE *file = fopen(path.c_str(), "rb");
void ViewPatternEditor::loadPatternFile(const fs::path &path) {
File file(path, File::Mode::Read);
if (file.isValid()) {
auto code = file.readString();
if (file != nullptr) {
char *buffer;
fseek(file, 0, SEEK_END);
size_t size = ftell(file);
rewind(file);
buffer = new char[size + 1];
fread(buffer, size, 1, file);
buffer[size] = 0x00;
fclose(file);
this->evaluatePattern(buffer);
this->m_textEditor.SetText(buffer);
delete[] buffer;
this->evaluatePattern(code);
this->m_textEditor.SetText(code);
}
}

View File

@ -8,6 +8,7 @@
#include <functional>
#include <hex/api/imhex_api.hpp>
#include <hex/helpers/paths.hpp>
#define EVENT_DEF(event_name, ...) \
struct event_name final : public hex::Event<__VA_ARGS__> { \
@ -98,7 +99,7 @@ namespace hex {
namespace pl { class PatternData; }
/* Default Events */
EVENT_DEF(EventFileLoaded, std::string);
EVENT_DEF(EventFileLoaded, fs::path);
EVENT_DEF(EventFileUnloaded);
EVENT_DEF(EventDataChanged);
EVENT_DEF(EventPatternChanged, std::vector<pl::PatternData*>&);
@ -117,7 +118,7 @@ namespace hex {
EVENT_DEF(RequestSetPatternLanguageCode, std::string);
EVENT_DEF(RequestChangeWindowTitle, std::string);
EVENT_DEF(RequestCloseImHex, bool);
EVENT_DEF(RequestOpenFile, std::string);
EVENT_DEF(RequestOpenFile, fs::path);
EVENT_DEF(RequestChangeTheme, u32);
EVENT_DEF(RequestOpenPopup, std::string);
EVENT_DEF(RequestCreateProvider, std::string, hex::prv::Provider **);

View File

@ -6,31 +6,23 @@
#include <string_view>
#include <vector>
namespace hex {
#include <hex/helpers/paths.hpp>
template<typename T>
struct SizeSorter {
bool operator() (const T& lhs, const T& rhs) const {
return lhs.size() < rhs.size();
}
};
namespace hex {
class EncodingFile {
public:
enum class Type {
Thingy,
CSV
Thingy
};
EncodingFile() = default;
EncodingFile(Type type, const std::string &path);
EncodingFile(Type type, const fs::path &path);
[[nodiscard]] std::pair<std::string_view, size_t> getEncodingFor(const std::vector<u8> &buffer) const;
[[nodiscard]] size_t getLongestSequence() const { return this->m_longestSequence; }
bool valid() const {
return this->m_valid;
}
[[nodiscard]] bool valid() const { return this->m_valid; }
private:
void parseThingyFile(std::ifstream &content);

View File

@ -6,6 +6,8 @@
#include <string>
#include <vector>
#include <hex/helpers/paths.hpp>
#if defined(OS_MACOS)
#define off64_t off_t
#define fopen64 fopen
@ -24,7 +26,7 @@ namespace hex {
Create
};
explicit File(const std::string &path, Mode mode);
explicit File(const fs::path &path, Mode mode);
File();
File(const File&) = delete;
File(File &&other) noexcept;
@ -51,11 +53,11 @@ namespace hex {
void remove();
auto getHandle() { return this->m_file; }
const std::string& getPath() { return this->m_path; }
const fs::path& getPath() { return this->m_path; }
private:
FILE *m_file;
std::string m_path;
fs::path m_path;
};
}

View File

@ -3,6 +3,8 @@
#include <string>
#include <string_view>
#include <hex/helpers/paths.hpp>
struct _object;
typedef struct _object PyObject;
@ -14,12 +16,12 @@ namespace hex {
public:
LoaderScript() = delete;
static bool processFile(const std::string &scriptPath);
static bool processFile(const fs::path &scriptPath);
static void setFilePath(const std::string &filePath) { LoaderScript::s_filePath = filePath; }
static void setFilePath(const fs::path &filePath) { LoaderScript::s_filePath = filePath; }
static void setDataProvider(prv::Provider* provider) { LoaderScript::s_dataProvider = provider; }
private:
static inline std::string s_filePath;
static inline fs::path s_filePath;
static inline prv::Provider* s_dataProvider;
static PyObject* Py_getFilePath(PyObject *self, PyObject *args);

View File

@ -16,8 +16,8 @@ namespace hex {
public:
ProjectFile() = delete;
static bool load(const std::string &filePath);
static bool store(std::string filePath = "");
static bool load(const fs::path &filePath);
static bool store(fs::path filePath = { });
[[nodiscard]] static bool hasUnsavedChanges() {
return ProjectFile::s_hasUnsavedChanged;
@ -32,7 +32,7 @@ namespace hex {
EventManager::post<RequestChangeWindowTitle>(fs::path(getFilePath()).filename().string());
}
[[nodiscard]] static const std::string& getProjectFilePath() {
[[nodiscard]] static const fs::path& getProjectFilePath() {
return ProjectFile::s_currProjectFilePath;
}
@ -41,14 +41,14 @@ namespace hex {
}
[[nodiscard]] static const std::string& getFilePath() {
[[nodiscard]] static const fs::path& getFilePath() {
return ProjectFile::s_filePath;
}
static void setFilePath(const std::string &filePath) {
static void setFilePath(const fs::path &filePath) {
ProjectFile::s_filePath = filePath;
EventManager::post<RequestChangeWindowTitle>(fs::path(filePath).filename().string());
EventManager::post<RequestChangeWindowTitle>(filePath.filename().string());
}
@ -92,10 +92,10 @@ namespace hex {
}
private:
static std::string s_currProjectFilePath;
static fs::path s_currProjectFilePath;
static bool s_hasUnsavedChanged;
static std::string s_filePath;
static fs::path s_filePath;
static std::string s_pattern;
static Patches s_patches;
static std::list<ImHexApi::Bookmarks::Entry> s_bookmarks;

View File

@ -94,7 +94,7 @@ namespace hex {
static std::vector<ContentRegistry::DataFormatter::impl::Entry> dataFormatters;
static std::vector<ContentRegistry::FileHandler::impl::Entry> fileHandlers;
static std::list<std::string> recentFilePaths;
static std::list<fs::path> recentFilePaths;
static int mainArgc;
static char **mainArgv;

View File

@ -3,6 +3,7 @@
#include <hex.hpp>
#include <hex/helpers/concepts.hpp>
#include <hex/helpers/paths.hpp>
#include <array>
#include <bit>
@ -221,7 +222,7 @@ namespace hex {
Folder
};
void openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::string)> &callback, const std::string &defaultPath = {});
void openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback, const std::string &defaultPath = {});
float float16ToFloat32(u16 float16);

View File

@ -35,7 +35,7 @@ namespace hex::pl {
[[nodiscard]]
std::optional<std::vector<PatternData*>> executeString(prv::Provider *provider, const std::string &string, const std::map<std::string, Token::Literal> &envVars = { }, const std::map<std::string, Token::Literal> &inVariables = { });
[[nodiscard]]
std::optional<std::vector<PatternData*>> executeFile(prv::Provider *provider, const std::string &path, const std::map<std::string, Token::Literal> &envVars = { }, const std::map<std::string, Token::Literal> &inVariables = { });
std::optional<std::vector<PatternData*>> executeFile(prv::Provider *provider, const fs::path &path, const std::map<std::string, Token::Literal> &envVars = { }, const std::map<std::string, Token::Literal> &inVariables = { });
[[nodiscard]]
const std::vector<ASTNode*>& getCurrentAST() const;

View File

@ -31,7 +31,7 @@ namespace hex::prv {
virtual void resize(ssize_t newSize);
virtual void save();
virtual void saveAs(const std::string &path);
virtual void saveAs(const fs::path &path);
virtual void readRaw(u64 offset, void *buffer, size_t size) = 0;
virtual void writeRaw(u64 offset, const void *buffer, size_t size) = 0;

View File

@ -6,12 +6,12 @@
namespace hex {
EncodingFile::EncodingFile(Type type, const std::string &path) {
EncodingFile::EncodingFile(Type type, const fs::path &path) {
std::ifstream encodingFile(path.c_str());
switch (type) {
case Type::Thingy: parseThingyFile(encodingFile); break;
default: throw std::runtime_error("Invalid encoding file type");
default: return;
}
this->m_valid = true;

View File

@ -3,14 +3,14 @@
namespace hex {
File::File(const std::string &path, Mode mode) : m_path(path) {
File::File(const fs::path &path, Mode mode) : m_path(path) {
if (mode == File::Mode::Read)
this->m_file = fopen64(path.c_str(), "rb");
this->m_file = fopen64(path.string().c_str(), "rb");
else if (mode == File::Mode::Write)
this->m_file = fopen64(path.c_str(), "r+b");
this->m_file = fopen64(path.string().c_str(), "r+b");
if (mode == File::Mode::Create || (mode == File::Mode::Write && this->m_file == nullptr))
this->m_file = fopen64(path.c_str(), "w+b");
this->m_file = fopen64(path.string().c_str(), "w+b");
}
File::File() {
@ -105,7 +105,7 @@ namespace hex {
void File::remove() {
this->close();
std::remove(this->m_path.c_str());
std::remove(this->m_path.string().c_str());
}
}

View File

@ -18,7 +18,7 @@ using namespace std::literals::string_literals;
namespace hex {
PyObject* LoaderScript::Py_getFilePath(PyObject *self, PyObject *args) {
return PyUnicode_FromString(LoaderScript::s_filePath.c_str());
return PyUnicode_FromString(LoaderScript::s_filePath.string().c_str());
}
PyObject* LoaderScript::Py_addPatch(PyObject *self, PyObject *args) {
@ -178,7 +178,7 @@ namespace hex {
return createStructureType("union", args);
}
bool LoaderScript::processFile(const std::string &scriptPath) {
bool LoaderScript::processFile(const fs::path &scriptPath) {
Py_SetProgramName(Py_DecodeLocale((SharedData::mainArgv)[0], nullptr));
for (const auto &dir : hex::getPath(ImHexPath::Python)) {
@ -220,7 +220,7 @@ namespace hex {
}
File scriptFile(scriptPath, File::Mode::Read);
PyRun_SimpleFile(scriptFile.getHandle(), scriptPath.c_str());
PyRun_SimpleFile(scriptFile.getHandle(), scriptFile.getPath().string().c_str());
Py_Finalize();

View File

@ -9,10 +9,10 @@ using json = nlohmann::json;
namespace hex {
std::string ProjectFile::s_currProjectFilePath;
fs::path ProjectFile::s_currProjectFilePath;
bool ProjectFile::s_hasUnsavedChanged = false;
std::string ProjectFile::s_filePath;
fs::path ProjectFile::s_filePath;
std::string ProjectFile::s_pattern;
Patches ProjectFile::s_patches;
std::list<ImHexApi::Bookmarks::Entry> ProjectFile::s_bookmarks;
@ -39,7 +39,7 @@ namespace hex {
}
bool ProjectFile::load(const std::string &filePath) {
bool ProjectFile::load(const fs::path &filePath) {
ProjectFile::s_hasUnsavedChanged = false;
json projectFileData;
@ -48,7 +48,7 @@ namespace hex {
std::ifstream projectFile(filePath.c_str());
projectFile >> projectFileData;
ProjectFile::s_filePath = projectFileData["filePath"];
ProjectFile::s_filePath = fs::path(projectFileData["filePath"].get<std::string>());
ProjectFile::s_pattern = projectFileData["pattern"];
ProjectFile::s_patches = projectFileData["patches"].get<Patches>();
ProjectFile::s_dataProcessorContent = projectFileData["dataProcessor"];
@ -73,7 +73,7 @@ namespace hex {
return true;
}
bool ProjectFile::store(std::string filePath) {
bool ProjectFile::store(fs::path filePath) {
EventManager::post<EventProjectFileStore>();
json projectFileData;

View File

@ -44,7 +44,7 @@ namespace hex {
std::vector<ContentRegistry::DataFormatter::impl::Entry> SharedData::dataFormatters;
std::vector<ContentRegistry::FileHandler::impl::Entry> SharedData::fileHandlers;
std::list<std::string> SharedData::recentFilePaths;
std::list<fs::path> SharedData::recentFilePaths;
int SharedData::mainArgc;
char **SharedData::mainArgv;

View File

@ -208,7 +208,7 @@ namespace hex {
}
void openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(std::string)> &callback, const std::string &defaultPath) {
void openFileBrowser(const std::string &title, DialogMode mode, const std::vector<nfdfilteritem_t> &validExtensions, const std::function<void(fs::path)> &callback, const std::string &defaultPath) {
NFD::Init();
nfdchar_t *outPath;

View File

@ -149,7 +149,7 @@ namespace hex::pl {
return patterns;
}
std::optional<std::vector<PatternData*>> PatternLanguage::executeFile(prv::Provider *provider, const std::string &path, const std::map<std::string, Token::Literal> &envVars, const std::map<std::string, Token::Literal> &inVariables) {
std::optional<std::vector<PatternData*>> PatternLanguage::executeFile(prv::Provider *provider, const fs::path &path, const std::map<std::string, Token::Literal> &envVars, const std::map<std::string, Token::Literal> &inVariables) {
File file(path, File::Mode::Read);
return this->executeString(provider, file.readString(), envVars, inVariables);

View File

@ -32,7 +32,7 @@ namespace hex::prv {
}
void Provider::save() { }
void Provider::saveAs(const std::string &path) { }
void Provider::saveAs(const fs::path &path) { }
void Provider::resize(ssize_t newSize) { }