forked from lix-project/lix
Style tweaks
This commit is contained in:
parent
abd685d373
commit
0fac86fd6f
|
@ -67,17 +67,16 @@ struct ArchiveCompressionSink : CompressionSink
|
||||||
Sink & nextSink;
|
Sink & nextSink;
|
||||||
struct archive * archive;
|
struct archive * archive;
|
||||||
|
|
||||||
ArchiveCompressionSink(Sink & nextSink, std::string format, bool parallel, int _level = COMPRESSION_LEVEL_DEFAULT) : nextSink(nextSink) {
|
ArchiveCompressionSink(Sink & nextSink, std::string format, bool parallel, int level = COMPRESSION_LEVEL_DEFAULT) : nextSink(nextSink)
|
||||||
|
{
|
||||||
archive = archive_write_new();
|
archive = archive_write_new();
|
||||||
if (!archive) throw Error("failed to initialize libarchive");
|
if (!archive) throw Error("failed to initialize libarchive");
|
||||||
check(archive_write_add_filter_by_name(archive, format.c_str()), "couldn't initialize compression (%s)");
|
check(archive_write_add_filter_by_name(archive, format.c_str()), "couldn't initialize compression (%s)");
|
||||||
check(archive_write_set_format_raw(archive));
|
check(archive_write_set_format_raw(archive));
|
||||||
if (parallel) {
|
if (parallel)
|
||||||
check(archive_write_set_filter_option(archive, format.c_str(), "threads", "0"));
|
check(archive_write_set_filter_option(archive, format.c_str(), "threads", "0"));
|
||||||
}
|
if (level != COMPRESSION_LEVEL_DEFAULT)
|
||||||
if (_level != COMPRESSION_LEVEL_DEFAULT){
|
check(archive_write_set_filter_option(archive, format.c_str(), "compression-level", std::to_string(level).c_str()));
|
||||||
check(archive_write_set_filter_option(archive, format.c_str(), "compression-level", std::to_string(_level).c_str()));
|
|
||||||
}
|
|
||||||
// disable internal buffering
|
// disable internal buffering
|
||||||
check(archive_write_set_bytes_per_block(archive, 0));
|
check(archive_write_set_bytes_per_block(archive, 0));
|
||||||
// disable output padding
|
// disable output padding
|
||||||
|
@ -131,9 +130,10 @@ private:
|
||||||
struct NoneSink : CompressionSink
|
struct NoneSink : CompressionSink
|
||||||
{
|
{
|
||||||
Sink & nextSink;
|
Sink & nextSink;
|
||||||
NoneSink(Sink & nextSink, int level = COMPRESSION_LEVEL_DEFAULT) : nextSink(nextSink) {
|
NoneSink(Sink & nextSink, int level = COMPRESSION_LEVEL_DEFAULT) : nextSink(nextSink)
|
||||||
|
{
|
||||||
if (level != COMPRESSION_LEVEL_DEFAULT)
|
if (level != COMPRESSION_LEVEL_DEFAULT)
|
||||||
printError("Warning: requested compression level '%d' not supported by compression method 'none'", level);
|
warn("requested compression level '%d' not supported by compression method 'none'", level);
|
||||||
}
|
}
|
||||||
void finish() override { flush(); }
|
void finish() override { flush(); }
|
||||||
void write(std::string_view data) override { nextSink(data); }
|
void write(std::string_view data) override { nextSink(data); }
|
||||||
|
|
Loading…
Reference in a new issue