diff --git a/src/file_stat.cpp b/src/file_stat.cpp index ae1e310c..998abcd0 100644 --- a/src/file_stat.cpp +++ b/src/file_stat.cpp @@ -124,7 +124,7 @@ file_stat::file_stat(fs::path const& path) { status.type() == fs::file_type::not_found ? "file not found" : "unknown file type", - u8string_to_string(path.u8string()))); + path_to_utf8_string_sanitized(path))); } valid_fields_ = file_stat::mode_valid; diff --git a/src/writer/categorizer/incompressible_categorizer.cpp b/src/writer/categorizer/incompressible_categorizer.cpp index 3e3d9e21..348d767f 100644 --- a/src/writer/categorizer/incompressible_categorizer.cpp +++ b/src/writer/categorizer/incompressible_categorizer.cpp @@ -94,7 +94,7 @@ class incompressible_categorizer_job_ : public sequential_categorizer_job { auto stats = [this] { return fmt::format("{} -> incompressible blocks: {}/{}, overall " "compression ratio: {:.2f}%", - u8string_to_string(path_.u8string()), + path_to_utf8_string_sanitized(path_), incompressible_blocks_, total_blocks_, 100.0 * total_output_size_ / total_input_size_); }; diff --git a/src/writer/internal/entry.cpp b/src/writer/internal/entry.cpp index 99035b84..74cd0238 100644 --- a/src/writer/internal/entry.cpp +++ b/src/writer/internal/entry.cpp @@ -101,7 +101,7 @@ fs::path entry::fs_path() const { } std::string entry::path_as_string() const { - return u8string_to_string(fs_path().u8string()); + return path_to_utf8_string_sanitized(fs_path()); } std::string entry::dpath() const { @@ -412,7 +412,7 @@ void dir::remove_empty_dirs(progress& prog) { } std::shared_ptr dir::find(fs::path const& path) { - auto name = u8string_to_string(path.filename().u8string()); + auto name = path_to_utf8_string_sanitized(path.filename()); if (!lookup_ && entries_.size() >= 16) { populate_lookup_table(); @@ -452,7 +452,7 @@ const std::string& link::linkname() const { return link_; } void link::accept(entry_visitor& v, bool) { v.visit(this); } void link::scan(os_access const& os, progress& prog) { - link_ = u8string_to_string(os.read_symlink(fs_path()).u8string()); + link_ = path_to_utf8_string_sanitized(os.read_symlink(fs_path())); prog.original_size += size(); prog.symlink_size += size(); } diff --git a/src/writer/internal/inode_manager.cpp b/src/writer/internal/inode_manager.cpp index 996553b3..72867a51 100644 --- a/src/writer/internal/inode_manager.cpp +++ b/src/writer/internal/inode_manager.cpp @@ -351,7 +351,7 @@ class inode_ : public inode { if (mm) { if (auto size = mm->size(); size >= min_size) { return prog.create_context( - context, u8string_to_string(mm->path().u8string()), size); + context, path_to_utf8_string_sanitized(mm->path()), size); } } return nullptr; diff --git a/src/writer/rule_based_entry_filter.cpp b/src/writer/rule_based_entry_filter.cpp index 44a917f1..60e0a0c7 100644 --- a/src/writer/rule_based_entry_filter.cpp +++ b/src/writer/rule_based_entry_filter.cpp @@ -189,7 +189,7 @@ template void rule_based_entry_filter_::set_root_path( fs::path const& path) { // TODO: this whole thing needs to be windowsized - root_path_ = u8string_to_string(path.u8string()); + root_path_ = path_to_utf8_string_sanitized(path); if constexpr (kLocalPathSeparator != '/') { // Both '/' and '\\' are, surprisingly, valid path separators on Windows, diff --git a/src/writer/scanner.cpp b/src/writer/scanner.cpp index dd5a91a5..1efcbe0c 100644 --- a/src/writer/scanner.cpp +++ b/src/writer/scanner.cpp @@ -468,7 +468,7 @@ scanner_::add_entry(std::filesystem::path const& name, default: LOG_ERROR << "unsupported entry type: " << int(pe->type()) << " (" - << pe->fs_path() << ")"; + << pe->path_as_string() << ")"; prog.errors++; break; } @@ -553,7 +553,8 @@ scanner_::scan_tree(std::filesystem::path const& path, prog.dirs_scanned++; } catch (const std::system_error& e) { - LOG_ERROR << "cannot read directory `" << ppath + LOG_ERROR << "cannot read directory `" + << path_to_utf8_string_sanitized(ppath) << "`: " << exception_str(e); prog.errors++; }