sys: Moved more functions to libwolv
This commit is contained in:
parent
0dafb3d230
commit
fb2e668589
2
lib/external/libwolv
vendored
2
lib/external/libwolv
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 6742cbb5c464ae4dcd7c1d5d1a573403258000bd
|
Subproject commit f98c18807a961dfcbf19dae256361e6b99a265d2
|
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 714fb62cf47b171dae58bf2c5a95e82d4d8310a7
|
Subproject commit 0858a0a1a0309bacaa34670488f7643d53d91849
|
@ -48,7 +48,6 @@ if (APPLE)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES}
|
set(LIBIMHEX_SOURCES ${LIBIMHEX_SOURCES}
|
||||||
source/helpers/fs_macos.m
|
|
||||||
source/helpers/utils_macos.m)
|
source/helpers/utils_macos.m)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
@ -274,13 +274,6 @@ namespace hex {
|
|||||||
return iter != a.end();
|
return iter != a.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> requires requires(T t) { t.u8string(); }
|
|
||||||
std::string toUTF8String(const T &value) {
|
|
||||||
auto result = value.u8string();
|
|
||||||
|
|
||||||
return { result.begin(), result.end() };
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T, typename... VariantTypes>
|
template<typename T, typename... VariantTypes>
|
||||||
T get_or(const std::variant<VariantTypes...> &variant, T alt) {
|
T get_or(const std::variant<VariantTypes...> &variant, T alt) {
|
||||||
const T *value = std::get_if<T>(&variant);
|
const T *value = std::get_if<T>(&variant);
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/helpers/logger.hpp>
|
||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ namespace hex {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
this->m_handle = dlopen(hex::toUTF8String(path).c_str(), RTLD_LAZY);
|
this->m_handle = dlopen(wolv::util::toUTF8String(path).c_str(), RTLD_LAZY);
|
||||||
|
|
||||||
if (this->m_handle == nullptr) {
|
if (this->m_handle == nullptr) {
|
||||||
log::error("dlopen failed: {}!", dlerror());
|
log::error("dlopen failed: {}!", dlerror());
|
||||||
@ -69,7 +71,7 @@ namespace hex {
|
|||||||
bool Plugin::initializePlugin() const {
|
bool Plugin::initializePlugin() const {
|
||||||
const auto requestedVersion = getCompatibleVersion();
|
const auto requestedVersion = getCompatibleVersion();
|
||||||
if (requestedVersion != IMHEX_VERSION) {
|
if (requestedVersion != IMHEX_VERSION) {
|
||||||
log::error("Refused to load plugin '{}' which was built for a different version of ImHex: '{}'", hex::toUTF8String(this->m_path.filename()), requestedVersion);
|
log::error("Refused to load plugin '{}' which was built for a different version of ImHex: '{}'", wolv::util::toUTF8String(this->m_path.filename()), requestedVersion);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
#if defined(OS_MACOS)
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
char* getMacExecutableDirectoryPath(void) {
|
|
||||||
@autoreleasepool {
|
|
||||||
const char *pathString = [[[[[NSBundle mainBundle] executableURL] URLByDeletingLastPathComponent] path] UTF8String];
|
|
||||||
|
|
||||||
char *result = malloc(strlen(pathString) + 1);
|
|
||||||
strcpy(result, pathString);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char* getMacApplicationSupportDirectoryPath(void) {
|
|
||||||
@autoreleasepool {
|
|
||||||
NSError* error = nil;
|
|
||||||
NSURL* dirUrl = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory
|
|
||||||
inDomain:NSUserDomainMask
|
|
||||||
appropriateForURL:nil
|
|
||||||
create:YES
|
|
||||||
error:&error];
|
|
||||||
|
|
||||||
if (error != nil) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *pathString = [[[dirUrl URLByAppendingPathComponent:(@"imhex")] path] UTF8String];
|
|
||||||
|
|
||||||
char *result = malloc(strlen(pathString) + 1);
|
|
||||||
strcpy(result, pathString);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void macFree(void *ptr) {
|
|
||||||
free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -4,6 +4,7 @@
|
|||||||
#include <hex/helpers/fs.hpp>
|
#include <hex/helpers/fs.hpp>
|
||||||
|
|
||||||
#include <wolv/utils/guards.hpp>
|
#include <wolv/utils/guards.hpp>
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
#include <hex/providers/provider.hpp>
|
#include <hex/providers/provider.hpp>
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ namespace hex::magic {
|
|||||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Magic)) {
|
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Magic)) {
|
||||||
for (const auto &entry : std::fs::directory_iterator(dir, error)) {
|
for (const auto &entry : std::fs::directory_iterator(dir, error)) {
|
||||||
if (entry.is_regular_file() && ((sourceFiles && entry.path().extension().empty()) || (!sourceFiles && entry.path().extension() == ".mgc"))) {
|
if (entry.is_regular_file() && ((sourceFiles && entry.path().extension().empty()) || (!sourceFiles && entry.path().extension() == ".mgc"))) {
|
||||||
magicFiles += hex::toUTF8String(wolv::io::fs::toShortPath(entry.path())) + MAGIC_PATH_SEPARATOR;
|
magicFiles += wolv::util::toUTF8String(wolv::io::fs::toShortPath(entry.path())) + MAGIC_PATH_SEPARATOR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ namespace hex {
|
|||||||
curl_mime *mime = curl_mime_init(this->m_ctx);
|
curl_mime *mime = curl_mime_init(this->m_ctx);
|
||||||
curl_mimepart *part = curl_mime_addpart(mime);
|
curl_mimepart *part = curl_mime_addpart(mime);
|
||||||
|
|
||||||
auto fileName = hex::toUTF8String(filePath.filename());
|
auto fileName = wolv::util::toUTF8String(filePath.filename());
|
||||||
curl_mime_data_cb(part, file.getSize(),
|
curl_mime_data_cb(part, file.getSize(),
|
||||||
[](char *buffer, size_t size, size_t nitems, void *arg) -> size_t {
|
[](char *buffer, size_t size, size_t nitems, void *arg) -> size_t {
|
||||||
auto file = static_cast<FILE*>(arg);
|
auto file = static_cast<FILE*>(arg);
|
||||||
|
@ -98,7 +98,7 @@ namespace hex::init {
|
|||||||
try {
|
try {
|
||||||
wolv::io::fs::createDirectories(folder);
|
wolv::io::fs::createDirectories(folder);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
log::error("Failed to create folder {}!", hex::toUTF8String(folder));
|
log::error("Failed to create folder {}!", wolv::util::toUTF8String(folder));
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ namespace hex::init {
|
|||||||
fonts->Clear();
|
fonts->Clear();
|
||||||
fonts->AddFontDefault(&cfg);
|
fonts->AddFontDefault(&cfg);
|
||||||
} else {
|
} else {
|
||||||
fonts->AddFontFromFileTTF(hex::toUTF8String(fontFile).c_str(), 0, &cfg, ranges.Data);
|
fonts->AddFontFromFileTTF(wolv::util::toUTF8String(fontFile).c_str(), 0, &cfg, ranges.Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge all fonts into one big font atlas
|
// Merge all fonts into one big font atlas
|
||||||
@ -333,7 +333,7 @@ namespace hex::init {
|
|||||||
|
|
||||||
// Initialize the plugin
|
// Initialize the plugin
|
||||||
if (!plugin.initializePlugin()) {
|
if (!plugin.initializePlugin()) {
|
||||||
log::error("Failed to initialize plugin {}", hex::toUTF8String(plugin.getPath().filename()));
|
log::error("Failed to initialize plugin {}", wolv::util::toUTF8String(plugin.getPath().filename()));
|
||||||
loadErrors++;
|
loadErrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ namespace hex::init {
|
|||||||
|
|
||||||
// Initialize the plugin
|
// Initialize the plugin
|
||||||
if (!plugin.initializePlugin()) {
|
if (!plugin.initializePlugin()) {
|
||||||
log::error("Failed to initialize plugin {}", hex::toUTF8String(plugin.getPath().filename()));
|
log::error("Failed to initialize plugin {}", wolv::util::toUTF8String(plugin.getPath().filename()));
|
||||||
loadErrors++;
|
loadErrors++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ namespace hex {
|
|||||||
if (data == nullptr) break;
|
if (data == nullptr) break;
|
||||||
|
|
||||||
std::fs::path path = data;
|
std::fs::path path = data;
|
||||||
log::info("Opening file in existing instance: {}", hex::toUTF8String(path));
|
log::info("Opening file in existing instance: {}", wolv::util::toUTF8String(path));
|
||||||
EventManager::post<RequestOpenFile>(path);
|
EventManager::post<RequestOpenFile>(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ namespace hex {
|
|||||||
|
|
||||||
// Save a backup project when the application crashes
|
// Save a backup project when the application crashes
|
||||||
EventManager::subscribe<EventAbnormalTermination>(this, [this](int) {
|
EventManager::subscribe<EventAbnormalTermination>(this, [this](int) {
|
||||||
ImGui::SaveIniSettingsToDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str());
|
ImGui::SaveIniSettingsToDisk(wolv::util::toUTF8String(this->m_imguiSettingsPath).c_str());
|
||||||
|
|
||||||
if (!ImHexApi::Provider::isDirty())
|
if (!ImHexApi::Provider::isDirty())
|
||||||
return;
|
return;
|
||||||
@ -441,7 +441,7 @@ namespace hex {
|
|||||||
const auto filePath = path / "builtin.hexplug";
|
const auto filePath = path / "builtin.hexplug";
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted(hex::toUTF8String(filePath).c_str());
|
ImGui::TextUnformatted(wolv::util::toUTF8String(filePath).c_str());
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TextUnformatted(wolv::io::fs::exists(filePath) ? ICON_VS_CHECK : ICON_VS_CLOSE);
|
ImGui::TextUnformatted(wolv::io::fs::exists(filePath) ? ICON_VS_CHECK : ICON_VS_CLOSE);
|
||||||
}
|
}
|
||||||
@ -868,7 +868,7 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this->m_imguiSettingsPath.empty() && wolv::io::fs::exists(this->m_imguiSettingsPath))
|
if (!this->m_imguiSettingsPath.empty() && wolv::io::fs::exists(this->m_imguiSettingsPath))
|
||||||
ImGui::LoadIniSettingsFromDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str());
|
ImGui::LoadIniSettingsFromDisk(wolv::util::toUTF8String(this->m_imguiSettingsPath).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplGlfw_InitForOpenGL(this->m_window, true);
|
ImGui_ImplGlfw_InitForOpenGL(this->m_window, true);
|
||||||
@ -893,7 +893,7 @@ namespace hex {
|
|||||||
void Window::exitImGui() {
|
void Window::exitImGui() {
|
||||||
delete static_cast<ImGui::ImHexCustomData *>(ImGui::GetIO().UserData);
|
delete static_cast<ImGui::ImHexCustomData *>(ImGui::GetIO().UserData);
|
||||||
|
|
||||||
ImGui::SaveIniSettingsToDisk(hex::toUTF8String(this->m_imguiSettingsPath).c_str());
|
ImGui::SaveIniSettingsToDisk(wolv::util::toUTF8String(this->m_imguiSettingsPath).c_str());
|
||||||
|
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
#include <hex/ui/imgui_imhex_extensions.h>
|
#include <hex/ui/imgui_imhex_extensions.h>
|
||||||
|
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
@ -259,12 +261,12 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string DiskProvider::getName() const {
|
std::string DiskProvider::getName() const {
|
||||||
return hex::toUTF8String(this->m_path);
|
return wolv::util::toUTF8String(this->m_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> DiskProvider::getDataDescription() const {
|
std::vector<std::pair<std::string, std::string>> DiskProvider::getDataDescription() const {
|
||||||
return {
|
return {
|
||||||
{ "hex.builtin.provider.disk.selected_disk"_lang, hex::toUTF8String(this->m_path) },
|
{ "hex.builtin.provider.disk.selected_disk"_lang, wolv::util::toUTF8String(this->m_path) },
|
||||||
{ "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(this->m_diskSize) },
|
{ "hex.builtin.provider.disk.disk_size"_lang, hex::toByteString(this->m_diskSize) },
|
||||||
{ "hex.builtin.provider.disk.sector_size"_lang, hex::toByteString(this->m_sectorSize) }
|
{ "hex.builtin.provider.disk.sector_size"_lang, hex::toByteString(this->m_sectorSize) }
|
||||||
};
|
};
|
||||||
@ -341,7 +343,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json DiskProvider::storeSettings(nlohmann::json settings) const {
|
nlohmann::json DiskProvider::storeSettings(nlohmann::json settings) const {
|
||||||
settings["path"] = hex::toUTF8String(this->m_path);
|
settings["path"] = wolv::util::toUTF8String(this->m_path);
|
||||||
|
|
||||||
return Provider::storeSettings(settings);
|
return Provider::storeSettings(settings);
|
||||||
}
|
}
|
||||||
@ -365,7 +367,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
std::variant<std::string, i128> DiskProvider::queryInformation(const std::string &category, const std::string &argument) {
|
std::variant<std::string, i128> DiskProvider::queryInformation(const std::string &category, const std::string &argument) {
|
||||||
if (category == "file_path")
|
if (category == "file_path")
|
||||||
return hex::toUTF8String(this->m_path);
|
return wolv::util::toUTF8String(this->m_path);
|
||||||
else if (category == "sector_size")
|
else if (category == "sector_size")
|
||||||
return this->m_sectorSize;
|
return this->m_sectorSize;
|
||||||
else
|
else
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
#include <hex/helpers/fmt.hpp>
|
#include <hex/helpers/fmt.hpp>
|
||||||
|
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
@ -169,13 +171,13 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string FileProvider::getName() const {
|
std::string FileProvider::getName() const {
|
||||||
return hex::toUTF8String(this->m_path.filename());
|
return wolv::util::toUTF8String(this->m_path.filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> FileProvider::getDataDescription() const {
|
std::vector<std::pair<std::string, std::string>> FileProvider::getDataDescription() const {
|
||||||
std::vector<std::pair<std::string, std::string>> result;
|
std::vector<std::pair<std::string, std::string>> result;
|
||||||
|
|
||||||
result.emplace_back("hex.builtin.provider.file.path"_lang, hex::toUTF8String(this->m_path));
|
result.emplace_back("hex.builtin.provider.file.path"_lang, wolv::util::toUTF8String(this->m_path));
|
||||||
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
|
result.emplace_back("hex.builtin.provider.file.size"_lang, hex::toByteString(this->getActualSize()));
|
||||||
|
|
||||||
if (this->m_fileStats.has_value()) {
|
if (this->m_fileStats.has_value()) {
|
||||||
@ -189,11 +191,11 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
std::variant<std::string, i128> FileProvider::queryInformation(const std::string &category, const std::string &argument) {
|
std::variant<std::string, i128> FileProvider::queryInformation(const std::string &category, const std::string &argument) {
|
||||||
if (category == "file_path")
|
if (category == "file_path")
|
||||||
return hex::toUTF8String(this->m_path);
|
return wolv::util::toUTF8String(this->m_path);
|
||||||
else if (category == "file_name")
|
else if (category == "file_name")
|
||||||
return hex::toUTF8String(this->m_path.filename());
|
return wolv::util::toUTF8String(this->m_path.filename());
|
||||||
else if (category == "file_extension")
|
else if (category == "file_extension")
|
||||||
return hex::toUTF8String(this->m_path.extension());
|
return wolv::util::toUTF8String(this->m_path.extension());
|
||||||
else if (category == "creation_time")
|
else if (category == "creation_time")
|
||||||
return this->m_fileStats->st_ctime;
|
return this->m_fileStats->st_ctime;
|
||||||
else if (category == "access_time")
|
else if (category == "access_time")
|
||||||
@ -253,9 +255,9 @@ namespace hex::plugin::builtin {
|
|||||||
nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const {
|
nlohmann::json FileProvider::storeSettings(nlohmann::json settings) const {
|
||||||
std::string path;
|
std::string path;
|
||||||
if (auto projectPath = ProjectFile::getPath(); !projectPath.empty())
|
if (auto projectPath = ProjectFile::getPath(); !projectPath.empty())
|
||||||
path = hex::toUTF8String(std::fs::proximate(this->m_path, projectPath.parent_path()));
|
path = wolv::util::toUTF8String(std::fs::proximate(this->m_path, projectPath.parent_path()));
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
path = hex::toUTF8String(this->m_path);
|
path = wolv::util::toUTF8String(this->m_path);
|
||||||
|
|
||||||
settings["path"] = path;
|
settings["path"] = path;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include <wolv/io/file.hpp>
|
#include <wolv/io/file.hpp>
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
@ -222,7 +223,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::string IntelHexProvider::getName() const {
|
[[nodiscard]] std::string IntelHexProvider::getName() const {
|
||||||
return hex::format("hex.builtin.provider.intel_hex.name"_lang, hex::toUTF8String(this->m_sourceFilePath.filename()));
|
return hex::format("hex.builtin.provider.intel_hex.name"_lang, wolv::util::toUTF8String(this->m_sourceFilePath.filename()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IntelHexProvider::handleFilePicker() {
|
bool IntelHexProvider::handleFilePicker() {
|
||||||
@ -274,7 +275,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json IntelHexProvider::storeSettings(nlohmann::json settings) const {
|
nlohmann::json IntelHexProvider::storeSettings(nlohmann::json settings) const {
|
||||||
settings["path"] = hex::toUTF8String(this->m_sourceFilePath);
|
settings["path"] = wolv::util::toUTF8String(this->m_sourceFilePath);
|
||||||
|
|
||||||
return Provider::storeSettings(settings);
|
return Provider::storeSettings(settings);
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <wolv/io/file.hpp>
|
#include <wolv/io/file.hpp>
|
||||||
#include <wolv/io/fs.hpp>
|
#include <wolv/io/fs.hpp>
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
namespace hex::plugin::builtin {
|
namespace hex::plugin::builtin {
|
||||||
|
|
||||||
@ -199,7 +200,7 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::string MotorolaSRECProvider::getName() const {
|
[[nodiscard]] std::string MotorolaSRECProvider::getName() const {
|
||||||
return hex::format("hex.builtin.provider.motorola_srec.name"_lang, hex::toUTF8String(this->m_sourceFilePath.filename()));
|
return hex::format("hex.builtin.provider.motorola_srec.name"_lang, wolv::util::toUTF8String(this->m_sourceFilePath.filename()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MotorolaSRECProvider::handleFilePicker() {
|
bool MotorolaSRECProvider::handleFilePicker() {
|
||||||
|
@ -402,7 +402,7 @@ namespace hex::plugin::builtin {
|
|||||||
if (ImGui::IconButton(ICON_VS_FOLDER_OPENED, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
if (ImGui::IconButton(ICON_VS_FOLDER_OPENED, ImGui::GetStyleColorVec4(ImGuiCol_Text))) {
|
||||||
return fs::openFileBrowser(fs::DialogMode::Open, { { "TTF Font", "ttf" }, { "OTF Font", "otf" } },
|
return fs::openFileBrowser(fs::DialogMode::Open, { { "TTF Font", "ttf" }, { "OTF Font", "otf" } },
|
||||||
[&](const std::fs::path &path) {
|
[&](const std::fs::path &path) {
|
||||||
fontPath = hex::toUTF8String(path);
|
fontPath = wolv::util::toUTF8String(path);
|
||||||
setting = fontPath;
|
setting = fontPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -461,7 +461,7 @@ namespace hex::plugin::builtin {
|
|||||||
} else {
|
} else {
|
||||||
for (size_t n = 0; n < userFolders.size(); n++) {
|
for (size_t n = 0; n < userFolders.size(); n++) {
|
||||||
const bool isSelected = (currentItemIndex == n);
|
const bool isSelected = (currentItemIndex == n);
|
||||||
if (ImGui::Selectable(hex::toUTF8String(userFolders.at(n)).c_str(), isSelected)) { currentItemIndex = n; }
|
if (ImGui::Selectable(wolv::util::toUTF8String(userFolders.at(n)).c_str(), isSelected)) { currentItemIndex = n; }
|
||||||
if (isSelected) { ImGui::SetItemDefaultFocus(); }
|
if (isSelected) { ImGui::SetItemDefaultFocus(); }
|
||||||
}
|
}
|
||||||
ImGui::EndListBox();
|
ImGui::EndListBox();
|
||||||
@ -576,7 +576,7 @@ namespace hex::plugin::builtin {
|
|||||||
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
|
for (const auto &dir : fs::getDefaultPaths(fs::ImHexPath::Resources)) {
|
||||||
auto path = dir / "font.ttf";
|
auto path = dir / "font.ttf";
|
||||||
if (wolv::io::fs::exists(path)) {
|
if (wolv::io::fs::exists(path)) {
|
||||||
log::info("Loading custom front from {}", hex::toUTF8String(path));
|
log::info("Loading custom front from {}", wolv::util::toUTF8String(path));
|
||||||
|
|
||||||
fontFile = path;
|
fontFile = path;
|
||||||
break;
|
break;
|
||||||
|
@ -619,7 +619,7 @@ namespace hex::plugin::builtin {
|
|||||||
try {
|
try {
|
||||||
auto json = nlohmann::json::parse(response.body);
|
auto json = nlohmann::json::parse(response.body);
|
||||||
links.push_back({
|
links.push_back({
|
||||||
hex::toUTF8String(currFile.filename()),
|
wolv::util::toUTF8String(currFile.filename()),
|
||||||
json["data"]["file"]["url"]["short"],
|
json["data"]["file"]["url"]["short"],
|
||||||
json["data"]["file"]["metadata"]["size"]["readable"]
|
json["data"]["file"]["metadata"]["size"]["readable"]
|
||||||
});
|
});
|
||||||
@ -974,7 +974,7 @@ namespace hex::plugin::builtin {
|
|||||||
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
|
if (ImGui::BeginListBox("##files", { -FLT_MIN, 10 * ImGui::GetTextLineHeightWithSpacing() })) {
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
for (auto &file : files) {
|
for (auto &file : files) {
|
||||||
if (ImGui::Selectable(hex::toUTF8String(file).c_str(), index == selectedIndex))
|
if (ImGui::Selectable(wolv::util::toUTF8String(file).c_str(), index == selectedIndex))
|
||||||
selectedIndex = index;
|
selectedIndex = index;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
@ -1064,7 +1064,7 @@ namespace hex::plugin::builtin {
|
|||||||
|
|
||||||
wolv::io::File input(file, wolv::io::File::Mode::Read);
|
wolv::io::File input(file, wolv::io::File::Mode::Read);
|
||||||
if (!input.isValid()) {
|
if (!input.isValid()) {
|
||||||
View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, hex::toUTF8String(file)));
|
View::showErrorPopup(hex::format("hex.builtin.tools.file_tools.combiner.open_input"_lang, wolv::util::toUTF8String(file)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::PushID(index);
|
ImGui::PushID(index);
|
||||||
|
|
||||||
bool selected = s_selectableFileIndices.contains(index);
|
bool selected = s_selectableFileIndices.contains(index);
|
||||||
if (ImGui::Selectable(hex::toUTF8String(path.filename()).c_str(), selected)) {
|
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), selected)) {
|
||||||
if (!s_selectableFileMultiple) {
|
if (!s_selectableFileMultiple) {
|
||||||
s_selectableFileIndices.clear();
|
s_selectableFileIndices.clear();
|
||||||
s_selectableFileIndices.insert(index);
|
s_selectableFileIndices.insert(index);
|
||||||
|
@ -172,9 +172,9 @@ namespace hex::plugin::builtin {
|
|||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
for (auto &path : fs::getDefaultPaths(type, true)){
|
for (auto &path : fs::getDefaultPaths(type, true)){
|
||||||
if(wolv::io::fs::isDirectory(path)){
|
if(wolv::io::fs::isDirectory(path)){
|
||||||
ImGui::TextUnformatted(hex::toUTF8String(path).c_str());
|
ImGui::TextUnformatted(wolv::util::toUTF8String(path).c_str());
|
||||||
}else{
|
}else{
|
||||||
ImGui::TextFormattedColored(ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed), hex::toUTF8String(path).c_str());
|
ImGui::TextFormattedColored(ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarRed), wolv::util::toUTF8String(path).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <hex/helpers/logger.hpp>
|
#include <hex/helpers/logger.hpp>
|
||||||
#include <hex/helpers/utils.hpp>
|
#include <hex/helpers/utils.hpp>
|
||||||
|
|
||||||
|
#include <wolv/utils/string.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
@ -54,7 +56,7 @@ namespace hex::plugin::builtin {
|
|||||||
this->m_constants.push_back(constant);
|
this->m_constants.push_back(constant);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
log::error("Failed to parse constants file {}", hex::toUTF8String(file.path()));
|
log::error("Failed to parse constants file {}", wolv::util::toUTF8String(file.path()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -506,13 +506,13 @@ namespace hex::plugin::builtin {
|
|||||||
entries.resize(this->m_possiblePatternFiles.size());
|
entries.resize(this->m_possiblePatternFiles.size());
|
||||||
|
|
||||||
for (u32 i = 0; i < entries.size(); i++) {
|
for (u32 i = 0; i < entries.size(); i++) {
|
||||||
entries[i] = hex::toUTF8String(this->m_possiblePatternFiles[i].filename());
|
entries[i] = wolv::util::toUTF8String(this->m_possiblePatternFiles[i].filename());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) {
|
if (ImGui::BeginListBox("##patterns_accept", ImVec2(-FLT_MIN, 0))) {
|
||||||
u32 index = 0;
|
u32 index = 0;
|
||||||
for (auto &path : this->m_possiblePatternFiles) {
|
for (auto &path : this->m_possiblePatternFiles) {
|
||||||
if (ImGui::Selectable(hex::toUTF8String(path.filename()).c_str(), index == this->m_selectedPatternFile))
|
if (ImGui::Selectable(wolv::util::toUTF8String(path.filename()).c_str(), index == this->m_selectedPatternFile))
|
||||||
this->m_selectedPatternFile = index;
|
this->m_selectedPatternFile = index;
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,8 @@ namespace hex::plugin::builtin {
|
|||||||
auto &extraData = ProviderExtraData::get(provider).yara;
|
auto &extraData = ProviderExtraData::get(provider).yara;
|
||||||
for (auto &[name, path] : extraData.rules) {
|
for (auto &[name, path] : extraData.rules) {
|
||||||
data["rules"].push_back({
|
data["rules"].push_back({
|
||||||
{ "name", hex::toUTF8String(name) },
|
{ "name", wolv::util::toUTF8String(name) },
|
||||||
{ "path", hex::toUTF8String(path) }
|
{ "path", wolv::util::toUTF8String(path) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace hex::plugin::builtin {
|
|||||||
if (ImGui::BeginListBox("##rules", ImVec2(-FLT_MIN, ImGui::GetTextLineHeightWithSpacing() * 5))) {
|
if (ImGui::BeginListBox("##rules", ImVec2(-FLT_MIN, ImGui::GetTextLineHeightWithSpacing() * 5))) {
|
||||||
for (u32 i = 0; i < rules.size(); i++) {
|
for (u32 i = 0; i < rules.size(); i++) {
|
||||||
const bool selected = (this->m_selectedRule == i);
|
const bool selected = (this->m_selectedRule == i);
|
||||||
if (ImGui::Selectable(hex::toUTF8String(rules[i].first).c_str(), selected)) {
|
if (ImGui::Selectable(wolv::util::toUTF8String(rules[i].first).c_str(), selected)) {
|
||||||
this->m_selectedRule = i;
|
this->m_selectedRule = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -264,7 +264,7 @@ namespace hex::plugin::builtin {
|
|||||||
yr_compiler_destroy(compiler);
|
yr_compiler_destroy(compiler);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto currFilePath = hex::toUTF8String(wolv::io::fs::toShortPath(filePath));
|
auto currFilePath = wolv::util::toUTF8String(wolv::io::fs::toShortPath(filePath));
|
||||||
|
|
||||||
yr_compiler_set_include_callback(
|
yr_compiler_set_include_callback(
|
||||||
compiler,
|
compiler,
|
||||||
|
Loading…
Reference in New Issue
Block a user