mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-11 13:30:47 -04:00
refactor: prefer raw strings for strings with lots of escapes
This commit is contained in:
parent
4b308e602e
commit
fabcf6d367
@ -563,17 +563,18 @@ void file_scanner_<LoggerPolicy>::dump_value(std::ostream& os,
|
|||||||
auto ino_num = p->inode_num();
|
auto ino_num = p->inode_num();
|
||||||
|
|
||||||
os << "{\n"
|
os << "{\n"
|
||||||
<< " \"ptr\": \""
|
<< R"( "ptr": ")"
|
||||||
<< fmt::format("{}", reinterpret_cast<void const*>(p)) << "\",\n"
|
<< fmt::format("{}", reinterpret_cast<void const*>(p)) << "\",\n"
|
||||||
<< " \"path\": " << nlohmann::json{p->path_as_string()}.dump()
|
<< R"( "path": )" << nlohmann::json{p->path_as_string()}.dump()
|
||||||
<< ",\n"
|
<< ",\n"
|
||||||
<< " \"size\": " << fmt::format("{}", p->size()) << ",\n"
|
<< R"( "size": )" << fmt::format("{}", p->size()) << ",\n"
|
||||||
<< " \"refcnt\": " << fmt::format("{}", p->refcount()) << ",\n"
|
<< R"( "refcnt": )" << fmt::format("{}", p->refcount()) << ",\n"
|
||||||
<< " \"hash\": \"" << folly::hexlify(p->hash()) << "\",\n"
|
<< R"( "hash": ")" << folly::hexlify(p->hash()) << "\",\n"
|
||||||
<< " \"invalid\": " << (p->is_invalid() ? "true" : "false") << ",\n"
|
<< R"( "invalid": )" << (p->is_invalid() ? "true" : "false")
|
||||||
<< " \"inode_num\": "
|
<< ",\n"
|
||||||
|
<< R"( "inode_num": )"
|
||||||
<< (ino_num ? fmt::format("{}", *ino_num) : "null") << ",\n"
|
<< (ino_num ? fmt::format("{}", *ino_num) : "null") << ",\n"
|
||||||
<< " \"inode\": \""
|
<< R"( "inode": ")"
|
||||||
<< fmt::format("{}", reinterpret_cast<void const*>(ino.get())) << "\"\n"
|
<< fmt::format("{}", reinterpret_cast<void const*>(ino.get())) << "\"\n"
|
||||||
<< " }";
|
<< " }";
|
||||||
}
|
}
|
||||||
@ -606,9 +607,9 @@ void file_scanner_<LoggerPolicy>::dump_inodes(std::ostream& os) const {
|
|||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
os << " {\n"
|
os << " {\n"
|
||||||
<< " \"ptr\": \""
|
<< R"( "ptr": ")"
|
||||||
<< fmt::format("{}", reinterpret_cast<void const*>(ino.get())) << "\",\n"
|
<< fmt::format("{}", reinterpret_cast<void const*>(ino.get())) << "\",\n"
|
||||||
<< " \"files\": ";
|
<< R"( "files": )";
|
||||||
dump_value(os, ino->all());
|
dump_value(os, ino->all());
|
||||||
os << "\n }";
|
os << "\n }";
|
||||||
}
|
}
|
||||||
@ -626,12 +627,12 @@ void file_scanner_<LoggerPolicy>::dump_inode_create_info(
|
|||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
os << " {\n"
|
os << " {\n"
|
||||||
<< " \"inode\": \""
|
<< R"( "inode": ")"
|
||||||
<< fmt::format("{}", reinterpret_cast<void const*>(ici.i)) << "\",\n"
|
<< fmt::format("{}", reinterpret_cast<void const*>(ici.i)) << "\",\n"
|
||||||
<< " \"file\": ";
|
<< R"( "file": )";
|
||||||
dump_value(os, ici.f);
|
dump_value(os, ici.f);
|
||||||
os << ",\n"
|
os << ",\n"
|
||||||
<< " \"line\": " << fmt::format("{}", ici.line) << "\n"
|
<< R"( "line": )" << fmt::format("{}", ici.line) << "\n"
|
||||||
<< " }";
|
<< " }";
|
||||||
}
|
}
|
||||||
os << "\n ]";
|
os << "\n ]";
|
||||||
|
@ -377,7 +377,7 @@ scanner_<LoggerPolicy>::add_entry(std::filesystem::path const& name,
|
|||||||
auto tmp [[maybe_unused]] = name.filename().u8string();
|
auto tmp [[maybe_unused]] = name.filename().u8string();
|
||||||
} catch (std::system_error const& e) {
|
} catch (std::system_error const& e) {
|
||||||
LOG_ERROR << fmt::format(
|
LOG_ERROR << fmt::format(
|
||||||
"invalid file name in \"{}\", storing as \"{}\": {}",
|
R"(invalid file name in "{}", storing as "{}": {})",
|
||||||
path_to_utf8_string_sanitized(name.parent_path()), pe->name(),
|
path_to_utf8_string_sanitized(name.parent_path()), pe->name(),
|
||||||
error_cp_to_utf8(e.what()));
|
error_cp_to_utf8(e.what()));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user