mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 20:41:04 -04:00
refactor(mkdwarfs): make output file logic easier to abstract
This commit is contained in:
parent
f41e6ac31f
commit
e8238c52f7
@ -1245,28 +1245,21 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
if (!options.debug_filter_function) {
|
if (!options.debug_filter_function) {
|
||||||
LOG_INFO << "compression CPU time: "
|
LOG_INFO << "compression CPU time: "
|
||||||
<< time_with_unit(wg_compress.get_cpu_time());
|
<< time_with_unit(wg_compress.get_cpu_time());
|
||||||
}
|
|
||||||
|
|
||||||
if (os) {
|
if (os) {
|
||||||
if (auto ofs = dynamic_cast<std::ofstream*>(os.get())) {
|
if (auto ofs = dynamic_cast<std::ofstream*>(os.get())) {
|
||||||
ofs->close();
|
ofs->close();
|
||||||
|
}
|
||||||
|
|
||||||
if (ofs->bad()) {
|
if (os->bad()) {
|
||||||
LOG_ERROR << "failed to close output file '" << output
|
LOG_ERROR << "failed to close output file '" << output
|
||||||
<< "': " << strerror(errno);
|
<< "': " << strerror(errno);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (auto oss [[maybe_unused]] =
|
|
||||||
dynamic_cast<std::ostringstream*>(os.get())) {
|
os.reset();
|
||||||
assert(oss->str().empty());
|
|
||||||
} else {
|
|
||||||
assert(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
os.reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!options.debug_filter_function) {
|
|
||||||
std::ostringstream err;
|
std::ostringstream err;
|
||||||
|
|
||||||
if (prog.errors) {
|
if (prog.errors) {
|
||||||
@ -1280,6 +1273,11 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
|
|
||||||
ti << "filesystem " << (recompress ? "rewritten " : "created ")
|
ti << "filesystem " << (recompress ? "rewritten " : "created ")
|
||||||
<< err.str();
|
<< err.str();
|
||||||
|
} else {
|
||||||
|
assert(os);
|
||||||
|
auto oss [[maybe_unused]] = dynamic_cast<std::ostringstream*>(os.get());
|
||||||
|
assert(oss);
|
||||||
|
assert(oss->str().empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
return prog.errors > 0;
|
return prog.errors > 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user