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);
}