1
0
mirror of synced 2024-11-28 17:40:51 +01:00
ImHex/plugins/builtin/source/content/workspaces.cpp

33 lines
1015 B
C++

#include <hex/api/content_registry.hpp>
#include <hex/api/task_manager.hpp>
#include <hex/api/workspace_manager.hpp>
#include <hex/helpers/fs.hpp>
namespace hex::plugin::builtin {
void loadWorkspaces() {
WorkspaceManager::reset();
for (const auto &defaultPath : fs::getDefaultPaths(fs::ImHexPath::Workspaces)) {
for (const auto &entry : std::fs::directory_iterator(defaultPath)) {
if (!entry.is_regular_file())
continue;
const auto &path = entry.path();
if (path.extension() != ".hexws")
continue;
WorkspaceManager::importFromFile(path);
}
}
std::string currentWorkspace = ContentRegistry::Settings::read<std::string>("hex.builtin.setting.general", "hex.builtin.setting.general.curr_workspace", "Default");
TaskManager::doLater([currentWorkspace] {
WorkspaceManager::switchWorkspace(currentWorkspace);
});
}
}