mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 13:37:42 -05:00
sys: Replaced many helper functions with libwolv
This commit is contained in:
@@ -338,7 +338,7 @@ namespace hex {
|
||||
this->m_fileSize = provider->getSize();
|
||||
|
||||
// Get a file reader
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
std::vector<u8> bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress);
|
||||
|
||||
this->processImpl(bytes);
|
||||
@@ -572,7 +572,7 @@ namespace hex {
|
||||
this->m_endAddress = endAddress;
|
||||
|
||||
// Get a file reader
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
std::vector<u8> bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress);
|
||||
|
||||
this->processImpl(bytes);
|
||||
@@ -685,7 +685,7 @@ namespace hex {
|
||||
this->m_fileSize = provider->getSize();
|
||||
|
||||
// Get a file reader
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
std::vector<u8> bytes = reader.read(this->m_startAddress, this->m_endAddress - this->m_startAddress);
|
||||
|
||||
this->processImpl(bytes);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
@@ -56,7 +57,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
protected:
|
||||
std::fs::path m_path;
|
||||
fs::File m_file;
|
||||
wolv::io::File m_file;
|
||||
size_t m_fileSize = 0;
|
||||
|
||||
std::optional<struct stat> m_fileStats;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <hex/helpers/socket.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
|
||||
#include <wolv/utils/socket.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <string_view>
|
||||
@@ -53,14 +54,14 @@ namespace hex::plugin::builtin {
|
||||
std::variant<std::string, i128> queryInformation(const std::string &category, const std::string &argument) override;
|
||||
|
||||
protected:
|
||||
hex::Socket m_socket;
|
||||
wolv::util::Socket m_socket;
|
||||
|
||||
std::string m_ipAddress;
|
||||
int m_port = 0;
|
||||
|
||||
u64 m_size = 0;
|
||||
|
||||
constexpr static size_t CacheLineSize = 0x1000;
|
||||
constexpr static size_t CacheLineSize = 0x10;
|
||||
|
||||
struct CacheLine {
|
||||
u64 address;
|
||||
@@ -69,6 +70,7 @@ namespace hex::plugin::builtin {
|
||||
};
|
||||
|
||||
std::list<CacheLine> m_cache;
|
||||
std::atomic<bool> m_resetCache = false;
|
||||
|
||||
std::thread m_cacheUpdateThread;
|
||||
std::mutex m_cacheLock;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
result += start;
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(offset);
|
||||
reader.setEndAddress(offset + size - 1);
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
result += HeaderLine;
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(offset);
|
||||
reader.setEndAddress((offset + size) - 1);
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace hex::plugin::builtin {
|
||||
" <code>\n"
|
||||
" <span class=\"offsetheader\">Hex View  00 01 02 03 04 05 06 07  08 09 0A 0B 0C 0D 0E 0F</span>";
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(offset);
|
||||
reader.setEndAddress((offset + size) - 1);
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include <implot.h>
|
||||
#include <hex/ui/imgui_imhex_extensions.h>
|
||||
|
||||
#include <wolv/utils/core.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
class NodeNullptr : public dp::Node {
|
||||
@@ -167,10 +170,10 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void process() override {
|
||||
this->setBufferOnOutput(0, hex::toBytes<u8>(u8(this->m_color.Value.x * 0xFF)));
|
||||
this->setBufferOnOutput(1, hex::toBytes<u8>(u8(this->m_color.Value.y * 0xFF)));
|
||||
this->setBufferOnOutput(2, hex::toBytes<u8>(u8(this->m_color.Value.z * 0xFF)));
|
||||
this->setBufferOnOutput(3, hex::toBytes<u8>(u8(this->m_color.Value.w * 0xFF)));
|
||||
this->setBufferOnOutput(0, wolv::util::toBytes<u8>(u8(this->m_color.Value.x * 0xFF)));
|
||||
this->setBufferOnOutput(1, wolv::util::toBytes<u8>(u8(this->m_color.Value.y * 0xFF)));
|
||||
this->setBufferOnOutput(2, wolv::util::toBytes<u8>(u8(this->m_color.Value.z * 0xFF)));
|
||||
this->setBufferOnOutput(3, wolv::util::toBytes<u8>(u8(this->m_color.Value.w * 0xFF)));
|
||||
}
|
||||
|
||||
void store(nlohmann::json &j) const override {
|
||||
@@ -1169,7 +1172,7 @@ namespace hex::plugin::builtin {
|
||||
const auto &outVars = pl.runtime->getOutVariables();
|
||||
|
||||
if (outVars.contains(this->m_name)) {
|
||||
std::visit(overloaded {
|
||||
std::visit(wolv::util::overloaded {
|
||||
[](const std::string &) {},
|
||||
[](pl::ptrn::Pattern *) {},
|
||||
[this](auto &&value) {
|
||||
@@ -1231,7 +1234,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void process() override {
|
||||
std::visit(overloaded {
|
||||
std::visit(wolv::util::overloaded {
|
||||
[this](i128 value) { this->setIntegerOnOutput(0, value); },
|
||||
[this](long double value) { this->setFloatOnOutput(0, value); },
|
||||
[this](const std::vector<u8> &value) { this->setBufferOnOutput(0, value); }
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
|
||||
#include <imgui.h>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <content/helpers/provider_extra_data.hpp>
|
||||
|
||||
#include <content/providers/file_provider.hpp>
|
||||
|
||||
#include <wolv/io/fs.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
static void openFile(const std::fs::path &path) {
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/api/keybinding.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
#include <hex/helpers/patches.hpp>
|
||||
|
||||
#include "content/global_actions.hpp"
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
@@ -122,7 +125,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.menu.file.import.base64"_lang)) {
|
||||
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
fs::File inputFile(path, fs::File::Mode::Read);
|
||||
wolv::io::File inputFile(path, wolv::io::File::Mode::Read);
|
||||
if (!inputFile.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.open_error"_lang);
|
||||
return;
|
||||
@@ -137,7 +140,7 @@ namespace hex::plugin::builtin {
|
||||
View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.import_error"_lang);
|
||||
else {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const std::fs::path &path) {
|
||||
fs::File outputFile(path, fs::File::Mode::Create);
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
|
||||
if (!outputFile.isValid())
|
||||
View::showErrorPopup("hex.builtin.menu.file.import.base64.popup.import_error"_lang);
|
||||
@@ -157,7 +160,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto patchData = fs::File(path, fs::File::Mode::Read).readBytes();
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPSPatch(patchData);
|
||||
if (!patch.has_value()) {
|
||||
handleIPSError(patch.error());
|
||||
@@ -183,7 +186,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.menu.file.import.ips32"_lang, nullptr, false)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto patchData = fs::File(path, fs::File::Mode::Read).readBytes();
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes();
|
||||
auto patch = hex::loadIPS32Patch(patchData);
|
||||
if (!patch.has_value()) {
|
||||
handleIPSError(patch.error());
|
||||
@@ -212,7 +215,7 @@ namespace hex::plugin::builtin {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &task) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
auto patchData = fs::File(path, fs::File::Mode::Read).readBytes();
|
||||
auto patchData = wolv::io::File(path, wolv::io::File::Mode::Read).readBytes();
|
||||
|
||||
if (patchData.size() != provider->getActualSize()) {
|
||||
View::showErrorPopup("hex.builtin.menu.file.import.modified_file.popup.invalid_size"_lang);
|
||||
@@ -254,7 +257,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [](const auto &path) {
|
||||
TaskManager::createTask("hex.builtin.common.processing", TaskManager::NoProgress, [path](auto &) {
|
||||
fs::File outputFile(path, fs::File::Mode::Create);
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
if (!outputFile.isValid()) {
|
||||
TaskManager::doLater([] {
|
||||
View::showErrorPopup("hex.builtin.menu.file.export.base64.popup.export_error"_lang);
|
||||
@@ -291,7 +294,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
TaskManager::doLater([data] {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const auto &path) {
|
||||
auto file = fs::File(path, fs::File::Mode::Create);
|
||||
auto file = wolv::io::File(path, wolv::io::File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.menu.file.export.ips.popup.export_error"_lang);
|
||||
return;
|
||||
@@ -322,7 +325,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
TaskManager::doLater([data] {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, {}, [&data](const auto &path) {
|
||||
auto file = fs::File(path, fs::File::Mode::Create);
|
||||
auto file = wolv::io::File(path, wolv::io::File::Mode::Create);
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.menu.file.export.ips.popup.export_error"_lang);
|
||||
return;
|
||||
|
||||
@@ -10,9 +10,12 @@
|
||||
#include "content/providers/view_provider.hpp"
|
||||
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void registerProviders() {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
@@ -77,7 +76,7 @@ namespace hex::plugin::builtin {
|
||||
return;
|
||||
|
||||
std::scoped_lock lock(this->m_mutex);
|
||||
fs::File writeFile(this->m_path, fs::File::Mode::Write);
|
||||
wolv::io::File writeFile(this->m_path, wolv::io::File::Mode::Write);
|
||||
if (!writeFile.isValid())
|
||||
return;
|
||||
|
||||
@@ -91,7 +90,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void FileProvider::saveAs(const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
|
||||
if (file.isValid()) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
@@ -113,7 +112,7 @@ namespace hex::plugin::builtin {
|
||||
this->close();
|
||||
|
||||
{
|
||||
fs::File file(this->m_path, fs::File::Mode::Write);
|
||||
wolv::io::File file(this->m_path, wolv::io::File::Mode::Write);
|
||||
|
||||
file.setSize(newSize);
|
||||
}
|
||||
@@ -221,7 +220,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_readable = true;
|
||||
this->m_writable = true;
|
||||
|
||||
fs::File file(this->m_path, fs::File::Mode::Read);
|
||||
wolv::io::File file(this->m_path, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) {
|
||||
this->m_writable = false;
|
||||
this->m_readable = false;
|
||||
|
||||
@@ -56,11 +56,15 @@ namespace hex::plugin::builtin {
|
||||
|
||||
}
|
||||
|
||||
void sendAck(Socket &socket) {
|
||||
void sendAck(wolv::util::Socket &socket) {
|
||||
socket.writeString("+");
|
||||
}
|
||||
|
||||
std::vector<u8> readMemory(Socket &socket, u64 address, size_t size) {
|
||||
void continueExecution(wolv::util::Socket &socket) {
|
||||
socket.writeString(createPacket("vCont;c"));
|
||||
}
|
||||
|
||||
std::vector<u8> readMemory(wolv::util::Socket &socket, u64 address, size_t size) {
|
||||
std::string packet = createPacket(hex::format("m{:X},{:X}", address, size));
|
||||
|
||||
socket.writeString(packet);
|
||||
@@ -84,7 +88,7 @@ namespace hex::plugin::builtin {
|
||||
return data;
|
||||
}
|
||||
|
||||
void writeMemory(Socket &socket, u64 address, const void *buffer, size_t size) {
|
||||
void writeMemory(wolv::util::Socket &socket, u64 address, const void *buffer, size_t size) {
|
||||
std::vector<u8> bytes(size);
|
||||
std::memcpy(bytes.data(), buffer, size);
|
||||
|
||||
@@ -94,10 +98,10 @@ namespace hex::plugin::builtin {
|
||||
|
||||
socket.writeString(packet);
|
||||
|
||||
auto receivedPacket = socket.readString(3);
|
||||
auto receivedPacket = socket.readString(6);
|
||||
}
|
||||
|
||||
bool enableNoAckMode(Socket &socket) {
|
||||
bool enableNoAckMode(wolv::util::Socket &socket) {
|
||||
socket.writeString(createPacket("QStartNoAckMode"));
|
||||
|
||||
auto ack = socket.readString(1);
|
||||
@@ -131,7 +135,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
bool GDBProvider::isWritable() const {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GDBProvider::isResizable() const {
|
||||
@@ -168,7 +172,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (cacheLine != this->m_cache.end())
|
||||
std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), size);
|
||||
std::memcpy(buffer, &cacheLine->data[0] + (offset % CacheLineSize), std::min(size, cacheLine->data.size()));
|
||||
} else {
|
||||
while (size > 0) {
|
||||
size_t readSize = std::min(size, CacheLineSize);
|
||||
@@ -251,22 +255,24 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
if (this->m_socket.isConnected()) {
|
||||
gdb::continueExecution(this->m_socket);
|
||||
|
||||
this->m_cacheUpdateThread = std::thread([this]() {
|
||||
auto cacheLine = this->m_cache.begin();
|
||||
while (this->isConnected()) {
|
||||
{
|
||||
std::scoped_lock lock(this->m_cacheLock);
|
||||
|
||||
if (this->m_resetCache) {
|
||||
this->m_cache.clear();
|
||||
this->m_resetCache = false;
|
||||
cacheLine = this->m_cache.begin();
|
||||
}
|
||||
|
||||
if (cacheLine != this->m_cache.end()) {
|
||||
auto data = gdb::readMemory(this->m_socket, cacheLine->address, 0x1000);
|
||||
std::vector<u8> data = gdb::readMemory(this->m_socket, cacheLine->address, CacheLineSize);
|
||||
|
||||
if (data.empty()) {
|
||||
this->m_cache.erase(cacheLine);
|
||||
cacheLine = this->m_cache.begin();
|
||||
continue;
|
||||
}
|
||||
|
||||
while (this->m_cache.size() > 5) {
|
||||
while (std::count_if(this->m_cache.begin(), this->m_cache.end(), [&](auto &line) { return !line.data.empty(); }) > 100) {
|
||||
this->m_cache.pop_front();
|
||||
cacheLine = this->m_cache.begin();
|
||||
}
|
||||
@@ -279,7 +285,7 @@ namespace hex::plugin::builtin {
|
||||
else
|
||||
cacheLine++;
|
||||
}
|
||||
std::this_thread::sleep_for(100ms);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
namespace intel_hex {
|
||||
@@ -192,7 +193,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
bool IntelHexProvider::open() {
|
||||
auto file = fs::File(this->m_sourceFilePath, fs::File::Mode::Read);
|
||||
auto file = wolv::io::File(this->m_sourceFilePath, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid())
|
||||
return false;
|
||||
|
||||
@@ -245,7 +246,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (!picked)
|
||||
return false;
|
||||
if (!fs::isRegularFile(this->m_sourceFilePath))
|
||||
if (!wolv::io::fs::isRegularFile(this->m_sourceFilePath))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/api/event.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
@@ -50,7 +51,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void MemoryFileProvider::saveAs(const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
|
||||
if (file.isValid()) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
|
||||
#include <hex/api/localization.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/io/fs.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
namespace motorola_srec {
|
||||
@@ -168,7 +170,7 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
bool MotorolaSRECProvider::open() {
|
||||
auto file = fs::File(this->m_sourceFilePath, fs::File::Mode::Read);
|
||||
auto file = wolv::io::File(this->m_sourceFilePath, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid())
|
||||
return false;
|
||||
|
||||
@@ -222,7 +224,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
if (!picked)
|
||||
return false;
|
||||
if (!fs::isRegularFile(this->m_sourceFilePath))
|
||||
if (!wolv::io::fs::isRegularFile(this->m_sourceFilePath))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
#include <ui/pattern_drawer.hpp>
|
||||
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace {
|
||||
|
||||
std::vector<std::fs::path> userFolders;
|
||||
@@ -566,14 +568,14 @@ namespace hex::plugin::builtin {
|
||||
|
||||
static void loadFontSettings() {
|
||||
std::fs::path fontFile = ContentRegistry::Settings::read("hex.builtin.setting.font", "hex.builtin.setting.font.font_path", "");
|
||||
if (!fs::exists(fontFile) || !fs::isRegularFile(fontFile))
|
||||
if (!wolv::io::fs::exists(fontFile) || !wolv::io::fs::isRegularFile(fontFile))
|
||||
fontFile.clear();
|
||||
|
||||
// If no custom font has been specified, search for a file called "font.ttf" in one of the resource folders
|
||||
if (fontFile.empty()) {
|
||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
|
||||
auto path = dir / "font.ttf";
|
||||
if (fs::exists(path)) {
|
||||
if (wolv::io::fs::exists(path)) {
|
||||
log::info("Loading custom front from {}", hex::toUTF8String(path));
|
||||
|
||||
fontFile = path;
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <hex/api/event.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
void registerThemeHandlers() {
|
||||
@@ -334,7 +335,7 @@ namespace hex::plugin::builtin {
|
||||
for (const auto &themeFolder : fs::getDefaultPaths(fs::ImHexPath::Themes)) {
|
||||
for (const auto &theme : std::fs::directory_iterator(themeFolder)) {
|
||||
if (theme.is_regular_file())
|
||||
api::ThemeManager::addTheme(fs::File(theme.path(), fs::File::Mode::Read).readString());
|
||||
api::ThemeManager::addTheme(wolv::io::File(theme.path(), wolv::io::File::Mode::Read).readString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <hex/helpers/net.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/literals.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/api/localization.hpp>
|
||||
@@ -27,6 +26,9 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
namespace {
|
||||
@@ -747,7 +749,7 @@ namespace hex::plugin::builtin {
|
||||
ON_SCOPE_EXIT {
|
||||
selectedFile.clear();
|
||||
};
|
||||
fs::File file(selectedFile, fs::File::Mode::Write);
|
||||
wolv::io::File file(selectedFile, wolv::io::File::Mode::Write);
|
||||
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.tools.file_tools.shredder.error.open"_lang);
|
||||
@@ -912,7 +914,7 @@ namespace hex::plugin::builtin {
|
||||
baseOutputPath.clear();
|
||||
};
|
||||
|
||||
fs::File file(selectedFile, fs::File::Mode::Read);
|
||||
wolv::io::File file(selectedFile, wolv::io::File::Mode::Read);
|
||||
|
||||
if (!file.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.tools.file_tools.splitter.picker.error.open"_lang);
|
||||
@@ -933,7 +935,7 @@ namespace hex::plugin::builtin {
|
||||
std::fs::path path = baseOutputPath;
|
||||
path += hex::format(".{:05}", index);
|
||||
|
||||
fs::File partFile(path, fs::File::Mode::Create);
|
||||
wolv::io::File partFile(path, wolv::io::File::Mode::Create);
|
||||
|
||||
if (!partFile.isValid()) {
|
||||
View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.splitter.picker.error.create"_lang, index));
|
||||
@@ -1046,7 +1048,7 @@ namespace hex::plugin::builtin {
|
||||
else {
|
||||
if (ImGui::Button("hex.builtin.tools.file_tools.combiner.combine"_lang)) {
|
||||
combinerTask = TaskManager::createTask("hex.builtin.tools.file_tools.combiner.combining", 0, [](auto &task) {
|
||||
fs::File output(outputPath, fs::File::Mode::Create);
|
||||
wolv::io::File output(outputPath, wolv::io::File::Mode::Create);
|
||||
|
||||
if (!output.isValid()) {
|
||||
View::showErrorPopup("hex.builtin.tools.file_tools.combiner.error.open_output"_lang);
|
||||
@@ -1060,14 +1062,14 @@ namespace hex::plugin::builtin {
|
||||
task.update(fileIndex);
|
||||
fileIndex++;
|
||||
|
||||
fs::File input(file, fs::File::Mode::Read);
|
||||
wolv::io::File input(file, wolv::io::File::Mode::Read);
|
||||
if (!input.isValid()) {
|
||||
View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, hex::toUTF8String(file)));
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr static auto BufferSize = 0xFF'FFFF;
|
||||
auto inputSize = input.getSize();
|
||||
auto inputSize = input.getSize();
|
||||
for (u64 inputOffset = 0; inputOffset < inputSize; inputOffset += BufferSize) {
|
||||
output.write(input.readBytes(std::min<u64>(BufferSize, inputSize - inputOffset)));
|
||||
output.flush();
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ImGui::TableNextColumn();
|
||||
for (auto &path : fs::getDefaultPaths(type, true)){
|
||||
if(fs::isDirectory(path)){
|
||||
if(wolv::io::fs::isDirectory(path)){
|
||||
ImGui::TextUnformatted(hex::toUTF8String(path).c_str());
|
||||
}else{
|
||||
ImGui::TextFormattedColored(ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed), hex::toUTF8String(path).c_str());
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/providers/provider.hpp>
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#include <content/helpers/provider_extra_data.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewBookmarks::ViewBookmarks() : View("hex.builtin.view.bookmarks.name") {
|
||||
@@ -388,7 +390,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.menu.file.bookmark.import"_lang, nullptr, false, providerValid)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { { "Bookmarks File", "hexbm"} }, [&](const std::fs::path &path) {
|
||||
try {
|
||||
importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(fs::File(path, fs::File::Mode::Read).readString()));
|
||||
importBookmarks(ImHexApi::Provider::get(), nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString()));
|
||||
} catch (...) { }
|
||||
});
|
||||
}
|
||||
@@ -397,7 +399,7 @@ namespace hex::plugin::builtin {
|
||||
nlohmann::json json;
|
||||
exportBookmarks(ImHexApi::Provider::get(), json);
|
||||
|
||||
fs::File(path, fs::File::Mode::Create).write(json.dump(4));
|
||||
wolv::io::File(path, wolv::io::File::Mode::Create).write(json.dump(4));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace hex::plugin::builtin {
|
||||
this->m_filterIndices.clear();
|
||||
|
||||
for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Constants)) {
|
||||
if (!fs::exists(path)) continue;
|
||||
if (!wolv::io::fs::exists(path)) continue;
|
||||
|
||||
std::error_code error;
|
||||
for (auto &file : std::fs::directory_iterator(path, error)) {
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <pl/pattern_language.hpp>
|
||||
#include <pl/core/evaluator.hpp>
|
||||
#include <pl/patterns/pattern.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
using NumberDisplayStyle = ContentRegistry::DataInspector::NumberDisplayStyle;
|
||||
@@ -106,7 +107,7 @@ namespace hex::plugin::builtin {
|
||||
if (!filePath.exists() || !filePath.is_regular_file() || filePath.path().extension() != ".hexpat")
|
||||
continue;
|
||||
|
||||
fs::File file(filePath, fs::File::Mode::Read);
|
||||
wolv::io::File file(filePath, wolv::io::File::Mode::Read);
|
||||
if (file.isValid()) {
|
||||
auto inspectorCode = file.readString();
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <hex/api/content_registry.hpp>
|
||||
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
|
||||
#include <hex/providers/provider.hpp>
|
||||
@@ -14,6 +13,8 @@
|
||||
|
||||
#include <content/helpers/provider_extra_data.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewDataProcessor::ViewDataProcessor() : View("hex.builtin.view.data_processor.name") {
|
||||
@@ -73,7 +74,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.load_processor"_lang, nullptr, false, providerValid)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Open, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } },
|
||||
[&](const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Read);
|
||||
if (file.isValid()) {
|
||||
ViewDataProcessor::loadNodes(data.mainWorkspace, file.readString());
|
||||
this->m_updateNodePositions = true;
|
||||
@@ -84,7 +85,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.view.data_processor.menu.file.save_processor"_lang, nullptr, false, !data.workspaceStack.empty() && !data.workspaceStack.back()->nodes.empty() && providerValid)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } },
|
||||
[&](const std::fs::path &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
if (file.isValid())
|
||||
file.write(ViewDataProcessor::saveNodes(data.mainWorkspace).dump(4));
|
||||
});
|
||||
@@ -92,7 +93,7 @@ namespace hex::plugin::builtin {
|
||||
});
|
||||
|
||||
ContentRegistry::FileHandler::add({ ".hexnode" }, [this](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) return false;
|
||||
|
||||
auto &data = ProviderExtraData::getCurrent().dataProcessor;
|
||||
@@ -204,7 +205,7 @@ namespace hex::plugin::builtin {
|
||||
for (const auto &entry : std::fs::recursive_directory_iterator(basePath)) {
|
||||
if (entry.path().extension() == ".hexnode") {
|
||||
try {
|
||||
nlohmann::json nodeJson = nlohmann::json::parse(fs::File(entry.path(), fs::File::Mode::Read).readString());
|
||||
nlohmann::json nodeJson = nlohmann::json::parse(wolv::io::File(entry.path(), wolv::io::File::Mode::Read).readString());
|
||||
|
||||
this->m_customNodes.push_back(CustomNode { LangEntry(nodeJson["name"]), nodeJson });
|
||||
} catch (nlohmann::json::exception &e) {
|
||||
@@ -320,7 +321,7 @@ namespace hex::plugin::builtin {
|
||||
if (it != workspace.nodes.end()) {
|
||||
auto &node = *it;
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"hex.builtin.view.data_processor.name"_lang, "hexnode" } }, [&](const std::fs::path &path){
|
||||
fs::File outputFile(path, fs::File::Mode::Create);
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
outputFile.write(ViewDataProcessor::saveNode(node.get()).dump(4));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -141,8 +141,8 @@ namespace hex::plugin::builtin {
|
||||
this->m_diffTask = TaskManager::createTask("Diffing...", commonSize, [this, providerA, providerB](Task &task) {
|
||||
std::vector<Diff> differences;
|
||||
|
||||
auto readerA = prv::BufferedReader(providerA);
|
||||
auto readerB = prv::BufferedReader(providerB);
|
||||
auto readerA = prv::ProviderReader(providerA);
|
||||
auto readerB = prv::ProviderReader(providerB);
|
||||
|
||||
for (auto itA = readerA.begin(), itB = readerB.begin(); itA < readerA.end() && itB < readerB.end(); itA++, itB++) {
|
||||
if (task.wasInterrupted())
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace hex::plugin::builtin {
|
||||
return results;
|
||||
}
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(searchRegion.getStartAddress());
|
||||
reader.setEndAddress(searchRegion.getEndAddress());
|
||||
|
||||
@@ -295,7 +295,7 @@ namespace hex::plugin::builtin {
|
||||
std::vector<ViewFind::Occurrence> ViewFind::searchSequence(Task &task, prv::Provider *provider, hex::Region searchRegion, const SearchSettings::Sequence &settings) {
|
||||
std::vector<Occurrence> results;
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(searchRegion.getStartAddress());
|
||||
reader.setEndAddress(searchRegion.getEndAddress());
|
||||
|
||||
@@ -353,7 +353,7 @@ namespace hex::plugin::builtin {
|
||||
std::vector<ViewFind::Occurrence> ViewFind::searchBinaryPattern(Task &task, prv::Provider *provider, hex::Region searchRegion, const SearchSettings::BinaryPattern &settings) {
|
||||
std::vector<Occurrence> results;
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(searchRegion.getStartAddress());
|
||||
reader.setEndAddress(searchRegion.getEndAddress());
|
||||
|
||||
@@ -386,7 +386,7 @@ namespace hex::plugin::builtin {
|
||||
std::vector<ViewFind::Occurrence> ViewFind::searchValue(Task &task, prv::Provider *provider, Region searchRegion, const SearchSettings::Value &settings) {
|
||||
std::vector<Occurrence> results;
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(searchRegion.getStartAddress());
|
||||
reader.setEndAddress(searchRegion.getEndAddress());
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace hex::plugin::builtin {
|
||||
std::optional<Region> findSequence(const std::vector<u8> &sequence, bool backwards) {
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
hex::prv::BufferedReader reader(provider);
|
||||
prv::ProviderReader reader(provider);
|
||||
|
||||
reader.seek(this->m_searchPosition.value_or(provider->getBaseAddress()));
|
||||
|
||||
@@ -605,7 +605,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto provider = ImHexApi::Provider::get();
|
||||
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader (provider);
|
||||
reader.seek(selection.getStartAddress());
|
||||
reader.setEndAddress(selection.getEndAddress());
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::FileHandler::add({ ".mgc" }, [](const auto &path) {
|
||||
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Magic)) {
|
||||
if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
||||
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
||||
View::showInfoPopup("hex.builtin.view.information.magic_db_added"_lang);
|
||||
return true;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ namespace hex::plugin::builtin {
|
||||
provider->getBaseAddress(), provider->getSize());
|
||||
|
||||
// Create a handle to the file
|
||||
auto reader = prv::BufferedReader(provider);
|
||||
auto reader = prv::ProviderReader(provider);
|
||||
reader.seek(provider->getBaseAddress() + this->m_inputStartAddress);
|
||||
reader.setEndAddress(provider->getBaseAddress() + this->m_inputEndAddress);
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
#include <hex/helpers/magic.hpp>
|
||||
|
||||
@@ -20,6 +19,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <chrono>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/io/fs.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
using namespace hex::literals;
|
||||
@@ -633,7 +636,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
|
||||
void ViewPatternEditor::loadPatternFile(const std::fs::path &path, prv::Provider *provider) {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Read);
|
||||
if (file.isValid()) {
|
||||
auto code = file.readString();
|
||||
|
||||
@@ -808,7 +811,7 @@ namespace hex::plugin::builtin {
|
||||
if (!entry.is_regular_file())
|
||||
continue;
|
||||
|
||||
fs::File file(entry.path(), fs::File::Mode::Read);
|
||||
wolv::io::File file(entry.path(), wolv::io::File::Mode::Read);
|
||||
if (!file.isValid())
|
||||
continue;
|
||||
|
||||
@@ -871,7 +874,7 @@ namespace hex::plugin::builtin {
|
||||
std::vector<std::fs::path> paths;
|
||||
|
||||
for (const auto &imhexPath : fs::getDefaultPaths(fs::ImHexPath::Patterns)) {
|
||||
if (!fs::exists(imhexPath)) continue;
|
||||
if (!wolv::io::fs::exists(imhexPath)) continue;
|
||||
|
||||
std::error_code error;
|
||||
for (auto &entry : std::fs::recursive_directory_iterator(imhexPath, error)) {
|
||||
@@ -890,7 +893,7 @@ namespace hex::plugin::builtin {
|
||||
if (ImGui::MenuItem("hex.builtin.view.pattern_editor.menu.file.save_pattern"_lang, nullptr, false, providerValid)) {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { {"Pattern", "hexpat"} },
|
||||
[this](const auto &path) {
|
||||
fs::File file(path, fs::File::Mode::Create);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Create);
|
||||
|
||||
file.write(this->m_textEditor.GetText());
|
||||
});
|
||||
@@ -969,7 +972,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
void ViewPatternEditor::registerHandlers() {
|
||||
ContentRegistry::FileHandler::add({ ".hexpat", ".pat" }, [](const std::fs::path &path) -> bool {
|
||||
fs::File file(path, fs::File::Mode::Read);
|
||||
wolv::io::File file(path, wolv::io::File::Mode::Read);
|
||||
|
||||
if (file.isValid()) {
|
||||
EventManager::post<RequestSetPatternLanguageCode>(file.readString());
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <hex/helpers/crypto.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/magic.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/tar.hpp>
|
||||
|
||||
@@ -19,6 +18,8 @@
|
||||
#include <functional>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
@@ -166,11 +167,11 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto path = folder / std::fs::path(storeEntry.fileName);
|
||||
|
||||
if (fs::exists(path) && fs::isPathWritable(folder)) {
|
||||
if (wolv::io::fs::exists(path) && fs::isPathWritable(folder)) {
|
||||
storeEntry.installed = true;
|
||||
|
||||
std::ifstream file(path, std::ios::in | std::ios::binary);
|
||||
std::vector<u8> data(fs::getFileSize(path), 0x00);
|
||||
std::vector<u8> data(wolv::io::fs::getFileSize(path), 0x00);
|
||||
file.read(reinterpret_cast<char *>(data.data()), data.size());
|
||||
|
||||
auto fileHash = crypt::sha256(data);
|
||||
@@ -227,7 +228,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
auto fullPath = path / std::fs::path(fileName);
|
||||
|
||||
if (!update || fs::exists(fullPath)) {
|
||||
if (!update || wolv::io::fs::exists(fullPath)) {
|
||||
downloading = true;
|
||||
this->m_downloadPath = fullPath;
|
||||
this->m_download = this->m_net.downloadFile(url, fullPath, 30'0000);
|
||||
@@ -249,10 +250,10 @@ namespace hex::plugin::builtin {
|
||||
const auto filePath = path / fileName;
|
||||
const auto folderPath = (path / std::fs::path(fileName).stem());
|
||||
|
||||
fs::remove(filePath);
|
||||
fs::removeAll(folderPath);
|
||||
wolv::io::fs::remove(filePath);
|
||||
wolv::io::fs::removeAll(folderPath);
|
||||
|
||||
removed = removed && !fs::exists(filePath) && !fs::exists(folderPath);
|
||||
removed = removed && !wolv::io::fs::exists(filePath) && !wolv::io::fs::exists(folderPath);
|
||||
}
|
||||
|
||||
return removed;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <hex/api/theme_manager.hpp>
|
||||
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <wolv/io/file.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace hex::plugin::builtin {
|
||||
fs::openFileBrowser(fs::DialogMode::Save, { { "ImHex Theme", "json" } }, [this](const std::fs::path &path){
|
||||
auto json = api::ThemeManager::exportCurrentTheme(this->m_themeName);
|
||||
|
||||
fs::File outputFile(path, fs::File::Mode::Create);
|
||||
wolv::io::File outputFile(path, wolv::io::File::Mode::Create);
|
||||
outputFile.write(json.dump(4));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
|
||||
#include "content/helpers/provider_extra_data.hpp"
|
||||
@@ -18,6 +17,10 @@
|
||||
#include <filesystem>
|
||||
#include <thread>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/io/fs.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::builtin {
|
||||
|
||||
ViewYara::ViewYara() : View("hex.builtin.view.yara.name") {
|
||||
@@ -25,7 +28,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
ContentRegistry::FileHandler::add({ ".yar", ".yara" }, [](const auto &path) {
|
||||
for (const auto &destPath : fs::getDefaultPaths(fs::ImHexPath::Yara)) {
|
||||
if (fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
||||
if (wolv::io::fs::copyFile(path, destPath / path.filename(), std::fs::copy_options::overwrite_existing)) {
|
||||
View::showInfoPopup("hex.builtin.view.yara.rule_added"_lang);
|
||||
return true;
|
||||
}
|
||||
@@ -261,12 +264,12 @@ namespace hex::plugin::builtin {
|
||||
yr_compiler_destroy(compiler);
|
||||
};
|
||||
|
||||
auto currFilePath = hex::toUTF8String(fs::toShortPath(filePath));
|
||||
auto currFilePath = hex::toUTF8String(wolv::io::fs::toShortPath(filePath));
|
||||
|
||||
yr_compiler_set_include_callback(
|
||||
compiler,
|
||||
[](const char *includeName, const char *, const char *, void *userData) -> const char * {
|
||||
fs::File file(std::fs::path(static_cast<const char *>(userData)).parent_path() / includeName, fs::File::Mode::Read);
|
||||
wolv::io::File file(std::fs::path(static_cast<const char *>(userData)).parent_path() / includeName, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid())
|
||||
return nullptr;
|
||||
|
||||
@@ -285,7 +288,7 @@ namespace hex::plugin::builtin {
|
||||
currFilePath.data()
|
||||
);
|
||||
|
||||
fs::File file(rules[this->m_selectedRule].second, fs::File::Mode::Read);
|
||||
wolv::io::File file(rules[this->m_selectedRule].second, wolv::io::File::Mode::Read);
|
||||
if (!file.isValid()) return;
|
||||
|
||||
if (yr_compiler_add_file(compiler, file.getHandle(), nullptr, nullptr) != 0) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <hex/ui/view.hpp>
|
||||
#include <hex/helpers/fs.hpp>
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/file.hpp>
|
||||
|
||||
#include <hex/api/project_file_manager.hpp>
|
||||
|
||||
@@ -18,6 +17,10 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <romfs/romfs.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/io/fs.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
#include <fonts/codicons_font.h>
|
||||
|
||||
#include <string>
|
||||
@@ -85,7 +88,7 @@ namespace hex::plugin::builtin {
|
||||
for (u32 i = 0; i < recentFilePaths.size() && uniqueProviders.size() < 5; i++) {
|
||||
auto &path = recentFilePaths[i];
|
||||
try {
|
||||
auto jsonData = nlohmann::json::parse(fs::File(path, fs::File::Mode::Read).readString());
|
||||
auto jsonData = nlohmann::json::parse(wolv::io::File(path, wolv::io::File::Mode::Read).readString());
|
||||
uniqueProviders.insert(RecentProvider {
|
||||
.displayName = jsonData["displayName"],
|
||||
.type = jsonData["type"],
|
||||
@@ -179,14 +182,14 @@ namespace hex::plugin::builtin {
|
||||
for (const auto &provider : ImHexApi::Provider::getProviders())
|
||||
provider->markDirty();
|
||||
|
||||
fs::remove(s_safetyBackupPath);
|
||||
wolv::io::fs::remove(s_safetyBackupPath);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::SetCursorPosX(width / 9 * 5);
|
||||
if (ImGui::Button("hex.builtin.welcome.safety_backup.delete"_lang, ImVec2(width / 3, 0))) {
|
||||
fs::remove(s_safetyBackupPath);
|
||||
wolv::io::fs::remove(s_safetyBackupPath);
|
||||
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
@@ -476,7 +479,7 @@ namespace hex::plugin::builtin {
|
||||
{
|
||||
for (const auto &recentPath : fs::getDefaultPaths(fs::ImHexPath::Recent)) {
|
||||
auto fileName = hex::format("{:%y%m%d_%H%M%S}.json", fmt::gmtime(std::chrono::system_clock::now()));
|
||||
fs::File recentFile(recentPath / fileName, fs::File::Mode::Create);
|
||||
wolv::io::File recentFile(recentPath / fileName, wolv::io::File::Mode::Create);
|
||||
if (!recentFile.isValid())
|
||||
continue;
|
||||
|
||||
@@ -550,7 +553,7 @@ namespace hex::plugin::builtin {
|
||||
|
||||
constexpr static auto CrashBackupFileName = "crash_backup.hexproj";
|
||||
for (const auto &path : fs::getDefaultPaths(fs::ImHexPath::Config)) {
|
||||
if (auto filePath = std::fs::path(path) / CrashBackupFileName; fs::exists(filePath)) {
|
||||
if (auto filePath = std::fs::path(path) / CrashBackupFileName; wolv::io::fs::exists(filePath)) {
|
||||
s_safetyBackupPath = filePath;
|
||||
TaskManager::doLater([] { ImGui::OpenPopup("hex.builtin.welcome.safety_backup.title"_lang); });
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
#include <hex/helpers/fmt.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
#include <wolv/io/file.hpp>
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::windows {
|
||||
|
||||
bool ProcessMemoryProvider::open() {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include <hex/helpers/utils.hpp>
|
||||
|
||||
#include <wolv/utils/guards.hpp>
|
||||
|
||||
namespace hex::plugin::windows {
|
||||
|
||||
ViewTTYConsole::ViewTTYConsole() : View("hex.windows.view.tty_console.name") {
|
||||
|
||||
Reference in New Issue
Block a user