mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-25 22:51:03 +00:00
Fix path key
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
bool is_subpath(const std::filesystem::path& root, const std::filesystem::path& p)
|
||||
bool is_subpath(const utils::path_key& root, const utils::path_key& p)
|
||||
{
|
||||
auto root_it = root.begin();
|
||||
auto p_it = p.begin();
|
||||
auto root_it = root.get().begin();
|
||||
auto p_it = p.get().begin();
|
||||
|
||||
for (; root_it != root.end(); ++root_it, ++p_it)
|
||||
for (; root_it != root.get().end(); ++root_it, ++p_it)
|
||||
{
|
||||
if (p_it == p.end() || *root_it != *p_it)
|
||||
if (p_it == p.get().end() || *root_it != *p_it)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -23,8 +23,7 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
void register_hive(registry_manager::hive_map& hives, const std::filesystem::path& key,
|
||||
const std::filesystem::path& file)
|
||||
void register_hive(registry_manager::hive_map& hives, const utils::path_key& key, const std::filesystem::path& file)
|
||||
{
|
||||
hives[key] = std::make_unique<hive_parser>(file);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ void registry_manager::deserialize(utils::buffer_deserializer& buffer)
|
||||
this->setup();
|
||||
}
|
||||
|
||||
std::filesystem::path registry_manager::normalize_path(const std::filesystem::path& path) const
|
||||
utils::path_key registry_manager::normalize_path(const utils::path_key& path) const
|
||||
{
|
||||
const utils::path_key canonical_path = path;
|
||||
|
||||
@@ -87,16 +86,16 @@ std::filesystem::path registry_manager::normalize_path(const std::filesystem::pa
|
||||
return canonical_path.get();
|
||||
}
|
||||
|
||||
void registry_manager::add_path_mapping(const std::filesystem::path& key, const std::filesystem::path& value)
|
||||
void registry_manager::add_path_mapping(const utils::path_key& key, const utils::path_key& value)
|
||||
{
|
||||
this->path_mapping_[key] = value;
|
||||
}
|
||||
|
||||
std::optional<registry_key> registry_manager::get_key(const std::filesystem::path& key)
|
||||
std::optional<registry_key> registry_manager::get_key(const utils::path_key& key)
|
||||
{
|
||||
const auto normal_key = this->normalize_path(key);
|
||||
|
||||
if (is_subpath(normal_key, "\\registry\\machine"))
|
||||
if (is_subpath(normal_key, utils::path_key{"\\registry\\machine"}))
|
||||
{
|
||||
registry_key reg_key{};
|
||||
reg_key.hive = normal_key;
|
||||
@@ -111,14 +110,14 @@ std::optional<registry_key> registry_manager::get_key(const std::filesystem::pat
|
||||
|
||||
registry_key reg_key{};
|
||||
reg_key.hive = iterator->first.get();
|
||||
reg_key.path = normal_key.lexically_relative(reg_key.hive);
|
||||
reg_key.path = normal_key.get().lexically_relative(reg_key.hive.get());
|
||||
|
||||
if (reg_key.path.empty())
|
||||
if (reg_key.path.get().empty())
|
||||
{
|
||||
return {std::move(reg_key)};
|
||||
}
|
||||
|
||||
const auto entry = iterator->second->get_sub_key(reg_key.path);
|
||||
const auto entry = iterator->second->get_sub_key(reg_key.path.get());
|
||||
if (!entry)
|
||||
{
|
||||
return std::nullopt;
|
||||
@@ -137,7 +136,7 @@ std::optional<registry_value> registry_manager::get_value(const registry_key& ke
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto* entry = iterator->second->get_value(key.path, name);
|
||||
auto* entry = iterator->second->get_value(key.path.get(), name);
|
||||
if (!entry)
|
||||
{
|
||||
return std::nullopt;
|
||||
@@ -151,11 +150,11 @@ std::optional<registry_value> registry_manager::get_value(const registry_key& ke
|
||||
return v;
|
||||
}
|
||||
|
||||
registry_manager::hive_map::iterator registry_manager::find_hive(const std::filesystem::path& key)
|
||||
registry_manager::hive_map::iterator registry_manager::find_hive(const utils::path_key& key)
|
||||
{
|
||||
for (auto i = this->hives_.begin(); i != this->hives_.end(); ++i)
|
||||
{
|
||||
if (is_subpath(i->first.get(), key))
|
||||
if (is_subpath(i->first, key))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user