forked from lix-project/lix
Remove makeDecompressionSource()
This function doesn't support all compression methods (i.e. 'none' and 'br') so it shouldn't be exposed. Also restore the original decompress() as a wrapper around makeDecompressionSink().
This commit is contained in:
parent
a6eebcff36
commit
5385755227
|
@ -186,19 +186,11 @@ struct BrotliDecompressionSink : ChunkedCompressionSink
|
||||||
|
|
||||||
ref<std::string> decompress(const std::string & method, const std::string & in)
|
ref<std::string> decompress(const std::string & method, const std::string & in)
|
||||||
{
|
{
|
||||||
if (method == "none" || method == "")
|
|
||||||
return make_ref<std::string>(in);
|
|
||||||
else if (method == "br") {
|
|
||||||
StringSink ssink;
|
StringSink ssink;
|
||||||
auto sink = makeDecompressionSink(method, ssink);
|
auto sink = makeDecompressionSink(method, ssink);
|
||||||
(*sink)(in);
|
(*sink)(in);
|
||||||
sink->finish();
|
sink->finish();
|
||||||
return ssink.s;
|
return ssink.s;
|
||||||
} else {
|
|
||||||
StringSource ssrc(in);
|
|
||||||
auto src = makeDecompressionSource(ssrc);
|
|
||||||
return make_ref<std::string>(src->drain());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Sink & nextSink)
|
std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Sink & nextSink)
|
||||||
|
@ -209,7 +201,7 @@ std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Si
|
||||||
return std::make_unique<BrotliDecompressionSink>(nextSink);
|
return std::make_unique<BrotliDecompressionSink>(nextSink);
|
||||||
else
|
else
|
||||||
return sourceToSink([&](Source & source) {
|
return sourceToSink([&](Source & source) {
|
||||||
auto decompressionSource = makeDecompressionSource(source);
|
auto decompressionSource = std::make_unique<ArchiveDecompressionSource>(source);
|
||||||
decompressionSource->drainInto(nextSink);
|
decompressionSource->drainInto(nextSink);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -267,11 +259,6 @@ struct BrotliCompressionSink : ChunkedCompressionSink
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Source> makeDecompressionSource(Source & prev)
|
|
||||||
{
|
|
||||||
return std::unique_ptr<Source>(new ArchiveDecompressionSource(prev));
|
|
||||||
}
|
|
||||||
|
|
||||||
ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel)
|
ref<CompressionSink> makeCompressionSink(const std::string & method, Sink & nextSink, const bool parallel)
|
||||||
{
|
{
|
||||||
std::vector<std::string> la_supports = {
|
std::vector<std::string> la_supports = {
|
||||||
|
|
|
@ -15,8 +15,6 @@ struct CompressionSink : BufferedSink, FinishSink
|
||||||
using FinishSink::finish;
|
using FinishSink::finish;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Source> makeDecompressionSource(Source & prev);
|
|
||||||
|
|
||||||
ref<std::string> decompress(const std::string & method, const std::string & in);
|
ref<std::string> decompress(const std::string & method, const std::string & in);
|
||||||
|
|
||||||
std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Sink & nextSink);
|
std::unique_ptr<FinishSink> makeDecompressionSink(const std::string & method, Sink & nextSink);
|
||||||
|
|
Loading…
Reference in a new issue