mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-07-09 17:25:18 -06:00
Use std::string_view in loader code
This commit is contained in:
parent
b8ca6d953f
commit
7a4ec42362
@ -396,24 +396,13 @@ namespace psf
|
|||||||
return found->second.as_integer();
|
return found->second.as_integer();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool check_registry(const registry& psf, std::function<bool(bool ok, const std::string& key, const entry& value)> validate, std::source_location src_loc)
|
bool check_registry(const registry& psf, std::source_location src_loc)
|
||||||
{
|
{
|
||||||
bool psf_ok = true;
|
bool psf_ok = true;
|
||||||
|
|
||||||
for (const auto& [key, value] : psf)
|
for (const auto& [key, value] : psf)
|
||||||
{
|
{
|
||||||
bool entry_ok = value.is_valid();
|
if (!value.is_valid())
|
||||||
|
|
||||||
if (validate)
|
|
||||||
{
|
|
||||||
// Validate against a custom condition as well (forward error)
|
|
||||||
if (!validate(entry_ok, key, value))
|
|
||||||
{
|
|
||||||
entry_ok = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry_ok)
|
|
||||||
{
|
{
|
||||||
if (value.type() == format::string)
|
if (value.type() == format::string)
|
||||||
{
|
{
|
||||||
@ -424,10 +413,7 @@ namespace psf
|
|||||||
// TODO: Better logging of other types
|
// TODO: Better logging of other types
|
||||||
psf_log.error("Entry %s is invalid.%s", key, value.as_string(), src_loc);
|
psf_log.error("Entry %s is invalid.%s", key, value.as_string(), src_loc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!entry_ok)
|
|
||||||
{
|
|
||||||
// Do not break, run over all entries in order to report all errors
|
// Do not break, run over all entries in order to report all errors
|
||||||
psf_ok = false;
|
psf_ok = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ namespace psf
|
|||||||
// Get integer value or default value
|
// Get integer value or default value
|
||||||
u32 get_integer(const registry& psf, std::string_view key, u32 def = 0);
|
u32 get_integer(const registry& psf, std::string_view key, u32 def = 0);
|
||||||
|
|
||||||
bool check_registry(const registry& psf, std::function<bool(bool ok, const std::string& key, const entry& value)> validate = {}, std::source_location src_loc = std::source_location::current());
|
bool check_registry(const registry& psf, std::source_location src_loc = std::source_location::current());
|
||||||
|
|
||||||
// Assign new entry
|
// Assign new entry
|
||||||
inline void assign(registry& psf, std::string_view key, entry&& _entry)
|
inline void assign(registry& psf, std::string_view key, entry&& _entry)
|
||||||
|
|||||||
@ -565,11 +565,11 @@ void tar_object::save_directory(const std::string& target_path, utils::serial& a
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto save_header = [&](const fs::stat_t& stat, const std::string& name)
|
auto save_header = [&](const fs::stat_t& stat, std::string_view name)
|
||||||
{
|
{
|
||||||
static_assert(sizeof(TARHeader) == 512);
|
static_assert(sizeof(TARHeader) == 512);
|
||||||
|
|
||||||
std::string_view saved_path{name.size() == src_dir_pos ? name.c_str() : &::at32(name, src_dir_pos), name.size() - src_dir_pos};
|
std::string_view saved_path = name.size() == src_dir_pos ? name : name.substr(src_dir_pos);
|
||||||
|
|
||||||
if (is_null)
|
if (is_null)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user