mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Tweaked GZIPDecompressorInputStream to no longer need a bool flag for the type of stream.
This commit is contained in:
parent
8977b896ab
commit
f89943d5f1
3 changed files with 12 additions and 15 deletions
|
|
@ -90,7 +90,7 @@ namespace zlibNamespace
|
|||
class GZIPDecompressorInputStream::GZIPDecompressHelper
|
||||
{
|
||||
public:
|
||||
GZIPDecompressHelper (const bool dontWrap)
|
||||
GZIPDecompressHelper()
|
||||
: finished (true),
|
||||
needsDictionary (false),
|
||||
error (true),
|
||||
|
|
@ -100,7 +100,7 @@ public:
|
|||
{
|
||||
using namespace zlibNamespace;
|
||||
zerostruct (stream);
|
||||
streamIsValid = (inflateInit2 (&stream, dontWrap ? -MAX_WBITS : MAX_WBITS) == Z_OK);
|
||||
streamIsValid = (inflateInit2 (&stream, MAX_WBITS + 32 /* auto-detect gzip encoding */) == Z_OK);
|
||||
finished = error = ! streamIsValid;
|
||||
}
|
||||
|
||||
|
|
@ -172,30 +172,27 @@ private:
|
|||
//==============================================================================
|
||||
GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream* const source,
|
||||
const bool deleteSourceWhenDestroyed,
|
||||
const bool noWrap_,
|
||||
const int64 uncompressedStreamLength_)
|
||||
const int64 uncompressedLength)
|
||||
: sourceStream (source, deleteSourceWhenDestroyed),
|
||||
uncompressedStreamLength (uncompressedStreamLength_),
|
||||
noWrap (noWrap_),
|
||||
uncompressedStreamLength (uncompressedLength),
|
||||
isEof (false),
|
||||
activeBufferSize (0),
|
||||
originalSourcePos (source->getPosition()),
|
||||
currentPos (0),
|
||||
buffer ((size_t) GZIPDecompressHelper::gzipDecompBufferSize),
|
||||
helper (new GZIPDecompressHelper (noWrap_))
|
||||
helper (new GZIPDecompressHelper())
|
||||
{
|
||||
}
|
||||
|
||||
GZIPDecompressorInputStream::GZIPDecompressorInputStream (InputStream& source)
|
||||
: sourceStream (&source, false),
|
||||
uncompressedStreamLength (-1),
|
||||
noWrap (false),
|
||||
isEof (false),
|
||||
activeBufferSize (0),
|
||||
originalSourcePos (source.getPosition()),
|
||||
currentPos (0),
|
||||
buffer ((size_t) GZIPDecompressHelper::gzipDecompBufferSize),
|
||||
helper (new GZIPDecompressHelper (false))
|
||||
helper (new GZIPDecompressHelper())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -278,7 +275,7 @@ bool GZIPDecompressorInputStream::setPosition (int64 newPos)
|
|||
isEof = false;
|
||||
activeBufferSize = 0;
|
||||
currentPos = 0;
|
||||
helper = new GZIPDecompressHelper (noWrap);
|
||||
helper = new GZIPDecompressHelper();
|
||||
|
||||
sourceStream->setPosition (originalSourcePos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ public:
|
|||
*/
|
||||
GZIPDecompressorInputStream (InputStream* sourceStream,
|
||||
bool deleteSourceWhenDestroyed,
|
||||
bool noWrap = false,
|
||||
int64 uncompressedStreamLength = -1);
|
||||
|
||||
/** Creates a decompressor stream.
|
||||
|
|
@ -80,8 +79,7 @@ public:
|
|||
private:
|
||||
//==============================================================================
|
||||
OptionalScopedPointer<InputStream> sourceStream;
|
||||
const int64 uncompressedStreamLength;
|
||||
const bool noWrap;
|
||||
int64 uncompressedStreamLength;
|
||||
bool isEof;
|
||||
int activeBufferSize;
|
||||
int64 originalSourcePos, currentPos;
|
||||
|
|
@ -91,6 +89,9 @@ private:
|
|||
friend struct ContainerDeletePolicy<GZIPDecompressHelper>;
|
||||
ScopedPointer<GZIPDecompressHelper> helper;
|
||||
|
||||
// NB: The old 'noWrap' parameter is no longer needed in the constructor
|
||||
JUCE_DEPRECATED (GZIPDecompressorInputStream (InputStream*, bool, bool));
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (GZIPDecompressorInputStream)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -298,8 +298,7 @@ InputStream* ZipFile::createStreamForEntry (const int index)
|
|||
|
||||
if (zei->compressed)
|
||||
{
|
||||
stream = new GZIPDecompressorInputStream (stream, true, true,
|
||||
zei->entry.uncompressedSize);
|
||||
stream = new GZIPDecompressorInputStream (stream, true, (int64) zei->entry.uncompressedSize);
|
||||
|
||||
// (much faster to unzip in big blocks using a buffer..)
|
||||
stream = new BufferedInputStream (stream, 32768, true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue