Restructure CompressSingleIntent
This commit is contained in:
parent
c8e6f51e1b
commit
92ac6586de
2 changed files with 18 additions and 14 deletions
|
@ -180,21 +180,23 @@ void ExtractIntent::execute() {
|
|||
}
|
||||
};
|
||||
|
||||
void CompressSingleIntent::execute() {
|
||||
path CompressSingleIntent::out_path() {
|
||||
if (this->out.has_value()) {
|
||||
if (!can_handle_archive(this->out.value())) {
|
||||
throw XwimError("Unknown archive format {}", this->out.value());
|
||||
}
|
||||
|
||||
unique_ptr<Archiver> archiver = make_archiver(this->out.value());
|
||||
set<path> ins{this->in};
|
||||
archiver->compress(ins, this->out.value());
|
||||
} else {
|
||||
path out = default_archive(strip_archive_extension(this->in).stem());
|
||||
return this->out.value();
|
||||
}
|
||||
|
||||
return default_archive(strip_archive_extension(this->in).stem());
|
||||
}
|
||||
|
||||
void CompressSingleIntent::execute() {
|
||||
path out = this->out_path();
|
||||
unique_ptr<Archiver> archiver = make_archiver(out);
|
||||
set<path> ins{this->in};
|
||||
archiver->compress(ins, out);
|
||||
}
|
||||
};
|
||||
|
||||
void CompressManyIntent::execute() {
|
||||
|
|
|
@ -57,6 +57,8 @@ private:
|
|||
path in;
|
||||
optional<path> out;
|
||||
|
||||
path out_path();
|
||||
|
||||
public:
|
||||
CompressSingleIntent(path in, optional<path> out) : UserIntent(), in(in), out(out) {};
|
||||
~CompressSingleIntent() override = default;
|
||||
|
|
Loading…
Reference in a new issue