mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
Add getTruncatedBytesString() to utils.
This commit is contained in:
parent
0e39d48214
commit
0f16231638
2 changed files with 20 additions and 0 deletions
18
src/util.cpp
18
src/util.cpp
|
@ -97,4 +97,22 @@ void nstool::writeStreamToStream(const std::shared_ptr<tc::io::IStream>& in_stre
|
|||
|
||||
remaining_data -= int64_t(cache_read_len);
|
||||
}
|
||||
}
|
||||
|
||||
std::string nstool::getTruncatedBytesString(const byte_t* data, size_t len, bool do_not_truncate)
|
||||
{
|
||||
if (data == nullptr) { return fmt::format(""); }
|
||||
|
||||
std::string str = "";
|
||||
|
||||
if (len <= 8 || do_not_truncate)
|
||||
{
|
||||
str = tc::cli::FormatUtil::formatBytesAsString(data, len, true, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
str = fmt::format("{:02X}{:02X}{:02X}{:02X}...{:02X}{:02X}{:02X}{:02X}", data[0], data[1], data[2], data[3], data[len-4], data[len-3], data[len-2], data[len-1]);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
|
@ -10,4 +10,6 @@ void writeSubStreamToFile(const std::shared_ptr<tc::io::IStream>& in_stream, int
|
|||
void writeStreamToFile(const std::shared_ptr<tc::io::IStream>& in_stream, const tc::io::Path& out_path, size_t cache_size = 0x10000);
|
||||
void writeStreamToStream(const std::shared_ptr<tc::io::IStream>& in_stream, const std::shared_ptr<tc::io::IStream>& out_stream, size_t cache_size = 0x10000);
|
||||
|
||||
std::string getTruncatedBytesString(const byte_t* data, size_t len, bool do_not_truncate);
|
||||
|
||||
}
|
Loading…
Reference in a new issue