2022-08-08 19:23:52 +00:00
|
|
|
#include <hex/api/project_file_manager.hpp>
|
|
|
|
|
|
|
|
#include <hex/helpers/tar.hpp>
|
|
|
|
#include <hex/helpers/fmt.hpp>
|
|
|
|
#include <hex/helpers/logger.hpp>
|
|
|
|
|
|
|
|
#include <hex/providers/provider.hpp>
|
|
|
|
|
2023-03-12 17:27:29 +00:00
|
|
|
#include <wolv/utils/guards.hpp>
|
|
|
|
#include <wolv/io/fs.hpp>
|
|
|
|
|
2022-08-08 19:23:52 +00:00
|
|
|
namespace hex {
|
|
|
|
|
|
|
|
std::vector<ProjectFile::Handler> ProjectFile::s_handlers;
|
|
|
|
std::vector<ProjectFile::ProviderHandler> ProjectFile::s_providerHandlers;
|
|
|
|
|
|
|
|
std::fs::path ProjectFile::s_currProjectPath;
|
|
|
|
|
2023-06-21 18:07:36 +00:00
|
|
|
std::function<bool(const std::fs::path&)> ProjectFile::s_loadProjectFunction;
|
|
|
|
std::function<bool(std::optional<std::fs::path>)> ProjectFile::s_storeProjectFunction;
|
2022-09-20 13:33:36 +00:00
|
|
|
|
2023-06-21 18:07:36 +00:00
|
|
|
void ProjectFile::setProjectFunctions(
|
|
|
|
const std::function<bool(const std::fs::path&)> &loadFun,
|
|
|
|
const std::function<bool(std::optional<std::fs::path>)> &storeFun
|
|
|
|
) {
|
|
|
|
ProjectFile::s_loadProjectFunction = loadFun;
|
|
|
|
ProjectFile::s_storeProjectFunction = storeFun;
|
|
|
|
}
|
2023-01-11 22:31:25 +00:00
|
|
|
|
2023-06-21 18:07:36 +00:00
|
|
|
bool ProjectFile::load(const std::fs::path &filePath) {
|
|
|
|
return s_loadProjectFunction(filePath);
|
2022-08-08 19:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ProjectFile::store(std::optional<std::fs::path> filePath) {
|
2023-06-21 18:07:36 +00:00
|
|
|
return s_storeProjectFunction(filePath);
|
2022-08-08 19:23:52 +00:00
|
|
|
}
|
|
|
|
|
2022-11-25 09:47:11 +00:00
|
|
|
bool ProjectFile::hasPath() {
|
|
|
|
return !ProjectFile::s_currProjectPath.empty();
|
|
|
|
}
|
|
|
|
|
2023-01-07 16:31:22 +00:00
|
|
|
void ProjectFile::clearPath() {
|
|
|
|
ProjectFile::s_currProjectPath.clear();
|
|
|
|
}
|
2023-02-12 16:52:09 +00:00
|
|
|
|
2023-01-07 16:31:22 +00:00
|
|
|
std::fs::path ProjectFile::getPath() {
|
|
|
|
return ProjectFile::s_currProjectPath;
|
|
|
|
}
|
|
|
|
|
2023-02-12 16:52:09 +00:00
|
|
|
void ProjectFile::setPath(const std::fs::path &path) {
|
|
|
|
ProjectFile::s_currProjectPath = path;
|
|
|
|
}
|
|
|
|
|
2022-08-08 19:23:52 +00:00
|
|
|
}
|