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 (this->out.has_value()) {
|
||||||
if (!can_handle_archive(this->out.value())) {
|
if (!can_handle_archive(this->out.value())) {
|
||||||
throw XwimError("Unknown archive format {}", this->out.value());
|
throw XwimError("Unknown archive format {}", this->out.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
unique_ptr<Archiver> archiver = make_archiver(this->out.value());
|
return this->out.value();
|
||||||
set<path> ins{this->in};
|
}
|
||||||
archiver->compress(ins, this->out.value());
|
|
||||||
} else {
|
return default_archive(strip_archive_extension(this->in).stem());
|
||||||
path out = default_archive(strip_archive_extension(this->in).stem());
|
}
|
||||||
unique_ptr<Archiver> archiver = make_archiver(out);
|
|
||||||
set<path> ins{this->in};
|
void CompressSingleIntent::execute() {
|
||||||
archiver->compress(ins, out);
|
path out = this->out_path();
|
||||||
}
|
unique_ptr<Archiver> archiver = make_archiver(out);
|
||||||
|
set<path> ins{this->in};
|
||||||
|
archiver->compress(ins, out);
|
||||||
};
|
};
|
||||||
|
|
||||||
void CompressManyIntent::execute() {
|
void CompressManyIntent::execute() {
|
||||||
|
|
|
@ -57,6 +57,8 @@ private:
|
||||||
path in;
|
path in;
|
||||||
optional<path> out;
|
optional<path> out;
|
||||||
|
|
||||||
|
path out_path();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CompressSingleIntent(path in, optional<path> out) : UserIntent(), in(in), out(out) {};
|
CompressSingleIntent(path in, optional<path> out) : UserIntent(), in(in), out(out) {};
|
||||||
~CompressSingleIntent() override = default;
|
~CompressSingleIntent() override = default;
|
||||||
|
|
Loading…
Reference in a new issue