StringUtil: Move IsPrintableCharacter() into Common namespace

This commit is contained in:
Lioncash committed 2023-05-16 14:17:54 -04:00
1 parent a9f1edeb61
commit 21df3ca572
9 files changed
+21 -18

No files matched your search

+1 -1
View File
@@ -193,7 +193,7 @@ void DisplayMessage(std::string message, int time_in_ms)
return;
// Actually displaying non-ASCII could cause things to go pear-shaped
if (!std::all_of(message.begin(), message.end(), IsPrintableCharacter))
if (!std::all_of(message.begin(), message.end(), Common::IsPrintableCharacter))
return;
OSD::AddMessage(std::move(message), time_in_ms);
+2 -2
View File
@@ -302,7 +302,7 @@ std::string TMDReader::GetGameID() const
std::memcpy(game_id, m_bytes.data() + offsetof(TMDHeader, title_id) + 4, 4);
std::memcpy(game_id + 4, m_bytes.data() + offsetof(TMDHeader, group_id), 2);
if (std::all_of(std::begin(game_id), std::end(game_id), IsPrintableCharacter))
if (std::all_of(std::begin(game_id), std::end(game_id), Common::IsPrintableCharacter))
return std::string(game_id, sizeof(game_id));
return fmt::format("{:016x}", GetTitleId());
@@ -313,7 +313,7 @@ std::string TMDReader::GetGameTDBID() const
const u8* begin = m_bytes.data() + offsetof(TMDHeader, title_id) + 4;
const u8* end = begin + 4;
if (std::all_of(begin, end, IsPrintableCharacter))
if (std::all_of(begin, end, Common::IsPrintableCharacter))
return std::string(begin, end);
return fmt::format("{:016x}", GetTitleId());
+4 -1
View File
@@ -474,8 +474,11 @@ ResultCode HostFileSystem::Format(Uid uid)
ResultCode HostFileSystem::CreateFileOrDirectory(Uid uid, Gid gid, const std::string& path,
FileAttribute attr, Modes modes, bool is_file)
{
if (!IsValidNonRootPath(path) || !std::all_of(path.begin(), path.end(), IsPrintableCharacter))
if (!IsValidNonRootPath(path) ||
!std::all_of(path.begin(), path.end(), Common::IsPrintableCharacter))
{
return ResultCode::Invalid;
}
if (!is_file && std::count(path.begin(), path.end(), '/') > int(MaxPathDepth))
return ResultCode::TooManyPathComponents;
+1 -1
View File
@@ -87,7 +87,7 @@ void V4GetUSStringMessage::OnTransferComplete(s32 return_value) const
auto& memory = system.GetMemory();
std::string message = memory.GetString(data_address);
std::replace_if(message.begin(), message.end(), std::not_fn(IsPrintableCharacter), '?');
std::replace_if(message.begin(), message.end(), std::not_fn(Common::IsPrintableCharacter), '?');
memory.CopyToEmu(data_address, message.c_str(), message.size());
TransferCommand::OnTransferComplete(return_value);
}