archive/bzip2: move bz2_fillbuffer into struct Bzip2InputStream
This commit is contained in:
parent
82b8f4f1ce
commit
438895842c
@ -103,6 +103,9 @@ struct Bzip2InputStream final : public InputStream {
|
|||||||
/* virtual methods from InputStream */
|
/* virtual methods from InputStream */
|
||||||
bool IsEOF() override;
|
bool IsEOF() override;
|
||||||
size_t Read(void *ptr, size_t size, Error &error) override;
|
size_t Read(void *ptr, size_t size, Error &error) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool FillBuffer(Error &error);
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain bz2_domain("bz2");
|
static constexpr Domain bz2_domain("bz2");
|
||||||
@ -175,24 +178,19 @@ Bzip2ArchiveFile::OpenStream(const char *path,
|
|||||||
return bis;
|
return bis;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
inline bool
|
||||||
bz2_fillbuffer(Bzip2InputStream *bis, Error &error)
|
Bzip2InputStream::FillBuffer(Error &error)
|
||||||
{
|
{
|
||||||
size_t count;
|
if (bzstream.avail_in > 0)
|
||||||
bz_stream *bzstream;
|
|
||||||
|
|
||||||
bzstream = &bis->bzstream;
|
|
||||||
|
|
||||||
if (bzstream->avail_in > 0)
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
count = bis->archive->istream->Read(bis->buffer, sizeof(bis->buffer),
|
size_t count = archive->istream->Read(buffer, sizeof(buffer),
|
||||||
error);
|
error);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bzstream->next_in = bis->buffer;
|
bzstream.next_in = buffer;
|
||||||
bzstream->avail_in = count;
|
bzstream.avail_in = count;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +207,7 @@ Bzip2InputStream::Read(void *ptr, size_t length, Error &error)
|
|||||||
bzstream.avail_out = length;
|
bzstream.avail_out = length;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!bz2_fillbuffer(this, error))
|
if (!FillBuffer(error))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
bz_result = BZ2_bzDecompress(&bzstream);
|
bz_result = BZ2_bzDecompress(&bzstream);
|
||||||
|
Loading…
Reference in New Issue
Block a user