sys: std::filesystem -> fs

This commit is contained in:
WerWolv
2022-01-13 14:33:30 +01:00
parent 27c08c1edf
commit c88d428fb5
24 changed files with 69 additions and 63 deletions

View File

@@ -1,13 +1,12 @@
#include "helpers/plugin_manager.hpp"
#include <hex/helpers/logger.hpp>
#include <hex/helpers/paths.hpp>
#include <filesystem>
namespace hex {
namespace fs = std::filesystem;
// hex::plugin::<pluginName>::internal::initializePlugin()
constexpr auto InitializePluginSymbol = "_ZN3hex6plugin{0}{1}8internal16initializePluginEv";
constexpr auto GetPluginNameSymbol = "_ZN3hex6plugin{0}{1}8internal13getPluginNameEv";
@@ -84,13 +83,13 @@ namespace hex {
this->m_setImGuiContextFunction(ctx);
}
bool PluginManager::load(const std::string &pluginFolder) {
if (!std::filesystem::exists(pluginFolder))
bool PluginManager::load(const fs::path &pluginFolder) {
if (!fs::exists(pluginFolder))
return false;
PluginManager::s_pluginFolder = pluginFolder;
for (auto& pluginPath : std::filesystem::directory_iterator(pluginFolder)) {
for (auto& pluginPath : fs::directory_iterator(pluginFolder)) {
if (pluginPath.is_regular_file() && pluginPath.path().extension() == ".hexplug")
PluginManager::s_plugins.emplace_back(pluginPath.path().string());
}

View File

@@ -25,7 +25,7 @@ namespace hex::init {
static bool checkForUpdates() {
hex::Net net;
auto releases = net.getJson(GitHubApiURL + "/releases/latest"s, 200).get();
auto releases = net.getJson(GitHubApiURL + "/releases/latest"s, 2000).get();
if (releases.code != 200)
return false;
@@ -72,7 +72,7 @@ namespace hex::init {
for (auto path : paths) {
for (auto &folder : hex::getPath(path, true)) {
try {
std::filesystem::create_directories(folder);
fs::create_directories(folder);
} catch (...) {
result = false;
}
@@ -92,10 +92,10 @@ namespace hex::init {
fonts = IM_NEW(ImFontAtlas)();
cfg = { };
std::string fontFile;
fs::path fontFile;
for (const auto &dir : hex::getPath(ImHexPath::Resources)) {
auto path = dir + "/font.ttf";
if (std::filesystem::exists(path)) {
auto path = dir / "font.ttf";
if (fs::exists(path)) {
fontFile = path;
break;
}
@@ -146,7 +146,7 @@ namespace hex::init {
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
cfg.SizePixels = fontSize * SharedData::fontScale;
fonts->AddFontFromFileTTF(fontFile.c_str(), std::floor(fontSize * SharedData::fontScale), &cfg, ranges.Data); // Needs conversion to char for Windows
fonts->AddFontFromFileTTF(fontFile.string().c_str(), std::floor(fontSize * SharedData::fontScale), &cfg, ranges.Data); // Needs conversion to char for Windows
}
cfg.MergeMode = true;

View File

@@ -237,7 +237,7 @@ namespace hex {
return;
for (const auto &path : hex::getPath(ImHexPath::Config)) {
if (ProjectFile::store((std::filesystem::path(path) / CrashBackupFileName).string()))
if (ProjectFile::store((fs::path(path) / CrashBackupFileName).string()))
break;
}
});
@@ -247,7 +247,7 @@ namespace hex {
});
for (const auto &path : hex::getPath(ImHexPath::Config)) {
if (auto filePath = std::filesystem::path(path) / CrashBackupFileName; std::filesystem::exists(filePath)) {
if (auto filePath = fs::path(path) / CrashBackupFileName; fs::exists(filePath)) {
this->m_safetyBackupPath = filePath;
View::doLater([]{ ImGui::OpenPopup("hex.safety_backup.title"_lang); });
}
@@ -478,14 +478,14 @@ namespace hex {
ProjectFile::markDirty();
ProjectFile::clearProjectFilePath();
std::filesystem::remove(this->m_safetyBackupPath);
fs::remove(this->m_safetyBackupPath);
ImGui::CloseCurrentPopup();
}
ImGui::SameLine();
ImGui::SetCursorPosX(width / 9 * 5);
if (ImGui::Button("hex.safety_backup.delete"_lang, ImVec2(width / 3, 0))) {
std::filesystem::remove(this->m_safetyBackupPath);
fs::remove(this->m_safetyBackupPath);
ImGui::CloseCurrentPopup();
}
@@ -630,7 +630,7 @@ namespace hex {
{
if (!SharedData::recentFilePaths.empty()) {
for (auto &path : SharedData::recentFilePaths) {
if (ImGui::BulletHyperlink(std::filesystem::path(path).filename().string().c_str())) {
if (ImGui::BulletHyperlink(fs::path(path).filename().string().c_str())) {
EventManager::post<RequestOpenFile>(path);
break;
}
@@ -997,7 +997,7 @@ namespace hex {
static std::string iniFileName;
for (const auto &dir : hex::getPath(ImHexPath::Config)) {
if (std::filesystem::exists(dir)) {
iniFileName = dir + "/interface.ini";
iniFileName = (dir / "interface.ini").string();
break;
}
}