diff --git a/uppsrc/Core/FilterStream.cpp b/uppsrc/Core/FilterStream.cpp index 1dc82d504..64726e380 100644 --- a/uppsrc/Core/FilterStream.cpp +++ b/uppsrc/Core/FilterStream.cpp @@ -13,6 +13,8 @@ void InFilterStream::Init() ptr = rdlim = h; in = NULL; eof = false; + style = STRM_READ|STRM_LOADING; + SetLoading(); } dword InFilterStream::Avail() @@ -100,7 +102,8 @@ void OutFilterStream::Init() wrlim = ~buffer + 4096; ptr = ~buffer; out = NULL; - count = 0; + count = in_count = 0; + style = STRM_WRITE; } OutFilterStream::~OutFilterStream() @@ -122,11 +125,18 @@ void OutFilterStream::Close() void OutFilterStream::FlushOut() { if(ptr != ~buffer) { - Filter(~buffer, (int)(ptr - ~buffer)); + int sz = (int)(ptr - ~buffer); + in_count += sz; + Filter(~buffer, sz); ptr = ~buffer; } } +int64 OutFilterStream::GetInCount() const +{ + return buffer ? in_count + (int)(ptr - ~buffer) : in_count; +} + void OutFilterStream::_Put(int w) { FlushOut(); diff --git a/uppsrc/Core/FilterStream.h b/uppsrc/Core/FilterStream.h index f2ae50c20..40e1c7f21 100644 --- a/uppsrc/Core/FilterStream.h +++ b/uppsrc/Core/FilterStream.h @@ -8,7 +8,7 @@ protected: virtual dword _Get(void *data, dword size); Vector buffer; - bool eof; + bool eof; void Init(); void Fetch(int size); @@ -44,6 +44,7 @@ protected: Buffer buffer; int64 count; + int64 in_count; void FlushOut(); dword Avail() { return dword(4096 - (ptr - ~buffer)); } @@ -56,6 +57,7 @@ public: void Out(const void *ptr, int size); int64 GetCount() const { return count; } + int64 GetInCount() const; template void Set(Stream& out_, F& filter) { diff --git a/uppsrc/Core/src.tpp/OutFilterStream$en-us.tpp b/uppsrc/Core/src.tpp/OutFilterStream$en-us.tpp index bba8e190b..0b047cfa2 100644 --- a/uppsrc/Core/src.tpp/OutFilterStream$en-us.tpp +++ b/uppsrc/Core/src.tpp/OutFilterStream$en-us.tpp @@ -49,7 +49,16 @@ size), also keeps track of output bytes written (see GetCount).&] [s4; &] [s5;:OutFilterStream`:`:GetCount`(`)const: [@(0.0.255) int64]_[* GetCount]()_[@(0.0.255) co nst]&] -[s2;%% Returns a number of bytes written to the output.&] +[s2;%% Returns a number of bytes written to the output stream (if +OutFilterStream is used for compression, this is the compressed +size). Note that this number is `'complete`' only after the OutFilterStream +is closed, because of buffering of data chunks.&] +[s3; &] +[s4; &] +[s5;:OutFilterStream`:`:GetInCount`(`)const: [@(0.0.255) int64]_[* GetInCount]()_[@(0.0.255) c +onst]&] +[s2;%% Returns a number of bytes written to OutFilterStream (if OutFilterStream +is used for compression, this is the uncompressed size).&] [s3; &] [s4;%% &] [s5;:OutFilterStream`:`:Set`(Stream`&`,F`&`): [@(0.0.255) template]_<[@(0.0.255) class]_[*@4 F