diff --git a/include/dwarfs/writer/fragment_order_parser.h b/include/dwarfs/writer/fragment_order_parser.h index 071d9e27..81594170 100644 --- a/include/dwarfs/writer/fragment_order_parser.h +++ b/include/dwarfs/writer/fragment_order_parser.h @@ -28,14 +28,25 @@ #include -namespace dwarfs::writer { +namespace dwarfs { + +class file_access; + +namespace writer { struct fragment_order_parser { public: static std::string choices(); + fragment_order_parser(std::shared_ptr const& fa) + : fa_{fa} {} + fragment_order_options parse(std::string_view arg) const; std::string to_string(fragment_order_options const& opts) const; + + private: + std::shared_ptr fa_; }; -} // namespace dwarfs::writer +} // namespace writer +} // namespace dwarfs diff --git a/src/writer/fragment_order_parser.cpp b/src/writer/fragment_order_parser.cpp index c14b3297..b83ffba4 100644 --- a/src/writer/fragment_order_parser.cpp +++ b/src/writer/fragment_order_parser.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -99,13 +100,16 @@ fragment_order_parser::parse(std::string_view arg) const { case fragment_order_mode::EXPLICIT: { auto file = om.get("file"); - std::ifstream ifs{file}; - if (!ifs) { - throw std::runtime_error( - fmt::format("failed to open explicit order file '{}'", file)); + std::error_code ec; + auto input = fa_->open_input(file, ec); + + if (ec) { + throw std::runtime_error(fmt::format( + "failed to open explicit order file '{}': {}", file, ec.message())); } + std::string line; - while (std::getline(ifs, line)) { + while (std::getline(input->is(), line)) { auto const path = std::filesystem::path{line}.relative_path(); rv.explicit_order[path] = rv.explicit_order.size(); } diff --git a/tools/src/mkdwarfs_main.cpp b/tools/src/mkdwarfs_main.cpp index 7ac8ea4e..5078fe73 100644 --- a/tools/src/mkdwarfs_main.cpp +++ b/tools/src/mkdwarfs_main.cpp @@ -414,7 +414,7 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) { integral_value_parser window_size_parser(0, 24); integral_value_parser window_step_parser(0, 8); integral_value_parser bloom_filter_size_parser(0, 10); - writer::fragment_order_parser order_parser; + writer::fragment_order_parser order_parser(iol.file); block_compressor_parser compressor_parser; writer::scanner_options options;