feat: unlinker auto paths (#848)

* chore: extract shared search paths code from modman

* feat: automatically detect search paths for game directories

* chore: adjust log levels for loading and unload search paths

* fix: move iwd to obj common
This commit is contained in:
Jan
2026-06-20 20:35:47 +02:00
committed by GitHub
parent b4477ac1a9
commit 087ce0c208
15 changed files with 336 additions and 292 deletions
+6 -33
View File
@@ -1,41 +1,15 @@
#pragma once
#include "SearchPath/SearchPaths.h"
#include "SearchPath/SharedSearchPaths.h"
#include "Zone/LoadedZoneInformation.h"
#include "Zone/Zone.h"
#include <expected>
#include <memory>
#include <shared_mutex>
#include <string>
#include <unordered_map>
#include <vector>
class ContextSearchPath
{
public:
explicit ContextSearchPath(std::unique_ptr<ISearchPath> searchPath);
std::unique_ptr<ISearchPath> m_search_path;
unsigned m_ref_count;
};
class LoadedZone
{
public:
LoadedZone(std::unique_ptr<Zone> zone, std::string filePath, std::vector<std::string> searchPaths);
[[nodiscard]] Zone& GetZone();
[[nodiscard]] const Zone& GetZone() const;
[[nodiscard]] const std::string& GetFilePath() const;
[[nodiscard]] const std::vector<std::string>& GetSearchPaths() const;
private:
std::unique_ptr<Zone> m_zone;
std::string m_file_path;
std::vector<std::string> m_search_paths;
};
template<class T> class ReadAccess
{
public:
@@ -60,17 +34,16 @@ class FastFileContext
public:
void Destroy();
std::expected<LoadedZone*, std::string> LoadFastFile(const std::string& path);
std::expected<LoadedZoneInformation*, std::string> LoadFastFile(const std::string& path);
std::expected<void, std::string> UnloadZone(const std::string& zoneName);
ReadAccess<const std::vector<std::unique_ptr<LoadedZone>>> GetLoadedZones();
ReadAccess<const std::vector<std::unique_ptr<LoadedZoneInformation>>> GetLoadedZones();
ReadAccess<ISearchPath> GetSearchPaths();
private:
std::vector<std::unique_ptr<LoadedZone>> m_loaded_zones;
std::vector<std::unique_ptr<LoadedZoneInformation>> m_loaded_zones;
std::shared_mutex m_zone_lock;
SearchPaths m_search_paths;
std::unordered_map<std::string, std::unique_ptr<ContextSearchPath>> m_context_search_paths;
SharedSearchPaths m_shared_search_paths;
std::shared_mutex m_search_path_lock;
};