|
|
Comments and Discussions
|
|
 |

|
Compiled with x64 architecture and got the following warnings:
zipstream.h(812): C4244: 'initializing' : conversion from 'std::streamsize' to 'int', possible loss of data
zipstream.h(859): C4267: 'argument' : conversion from 'size_t' to 'uInt', possible loss of data
zipstream.h(765): C4267: '=' : conversion from 'size_t' to 'uInt', possible loss of data
Please provide a fix!
|
|
|
|

|
I want to try out this library but how?
You wrote:
Using it in your project
Zlib wrapper
* Read the license terms,
* Copy zipstream.hpp and zipstream.ipp in your include directory,
* Make sure zlib is available,
* Add #include "zlibstream.hpp" to include the headers,
Where can I download the zipstream.hpp and zipstream.ipp? The zipstream_src.zip only contains a zip_stream_test.cpp and a zip_stream_test.hpp.
With the "Make sure zlib is available" phrase do you mean linking zlib.h and the zdll.lib? Just like this?
#include "zlibdll/include/zlib.h"
#pragma comment (lib, "zlibdll/lib/zdll.lib" )
Could you make this clear please?
|
|
|
|

|
Download the "Demo Project." It contains all of the files needed for both zlib and bzip2. It also includes a version of zlib as well.
"Make sure zlib is available," that means have proper linking and proper headers in your project.
|
|
|
|

|
Hello,
is anybody able to use this templates with GCC 4.x? It seems that a lot of things has WRT to internal STL declarations.
I know boost::iostream but it's a bit too heavy (ie. bloaty) for the simple purpose of bzip2 file reading.
|
|
|
|

|
zipstream is not necessary anymore, you can use the boost::iostreams lib instead
www.boost.org
|
|
|
|

|
I was trying to make zipstream works with boost::serialize, but gets a boost stream error every time I try to read the data back in, though there seems to be no problem with writing to file. Can anybody spot my mistake?
void save_forest_zip(const std::list &trees, const char * filename){
std::ofstream ofs(filename, std::ios::binary);
assert(ofs.good());
zlib_stream::zip_ostream zipos(ofs);
boost::archive::binary_oarchive oa(zipos);
oa << BOOST_SERIALIZATION_NVP(trees);
}
void restore_forest_zip(std::list &trees, const char * filename)
{
std::ifstream ifs(filename, std::ios::binary);
assert(ifs.good());
zlib_stream::zip_istream zipis(ifs);
boost::archive::binary_iarchive ia(zipis);
ia >> BOOST_SERIALIZATION_NVP(trees);
}
|
|
|
|

|
zipstream ifstream reading is broken.
try instead bzip2stream! here writing and reading from file-streams works fine! and bzip2 compresses better and is more portable. you can simply concat all .c files from bzip2 sources and include them into your project. no need to build a library for each platform you are developing.
|
|
|
|

|
As I'm not using the std namespace, in zipstream.ipp, I had to change ios and ios_base to std::ios and std::ios_base when using zip_istream to compile. Suggest either insert a using namespace std somewhere or qualify ios and ios_base fullly.
regards.
|
|
|
|

|
just wanted to notice you, that file2file zipping and unzipping with bzip2stream works fine. somehow zipstream file2file is broken. i asked Jonathan de Halleux if he could fix it, but he has no sparetime to do it. maybe someone here on the forums is able to do it?
but untial that i suggest to use bzip2. not only that it compresses better, the bzip2 library is about 10kbyte smaller than the zlib lib, if you are keen on saving programspace.
by the way: if you compress a targa - file using bzip2, the resulting file is SMALLER than the same image compressed with libpng (i think thats because libpng internally uses zlib?!?)
|
|
|
|

|
Has anyone got this to work on linux? If yes, what did you do?
After looking into it further, it works on linux if pondor's suggested fixes from the 'wrong version?' message are made and if lines 455 and 458 of zipstream.ipp are modified to include std::ios.......
|
|
|
|

|
It seems to have stopped working with GCC 3.4 though Lots of errors.
|
|
|
|

|
I'm also trying to make this work on Linux.
Has anyone had any luck?
Thanks,
Adam
|
|
|
|

|
I'm trying to verify that I can write a zip file with zip_ostream (looks good.. I think). But I cannot read the generated file with zip_istream i.e.:
std::ofstream os;
os.open("testfile.z", std::ios::binary);
{
zlib_stream::zip_ostream osz(os, std::ios::out, true);
osz << "Writing a lot of stuff!";
}
os.close();
std::ifstream is;
is.open("testfile.z", std::ios::binary);
zlib_stream::zip_istream isz(is);
while (!isz.eof())
{
char buf[512];
isz.read(buf, 512); << DOES NOT WORK!
int n = isz.gcount();
}
is.close();
What am I doing wrong ??
TIA
/Rob
|
|
|
|

|
Hi. The following program cause error. [assertion failed at (1) line] But it successed using zip_ostream scope. [at (2) line] Is this known problem? Environment: VC6 SP5, Win2000 SP4. <sample> const int BufferSize = 4080; const int LoopCnt = 5; char CheckBuffer[BufferSize]; for(int i = 0; i < BufferSize; ++i) { CheckBuffer[i] = i + 1; } char Zero[BufferSize]; memset(Zero, 0, BufferSize); char WorkBuffer[BufferSize]; { std::ofstream Out("c:\\test.bin", std::ios::out | std::ios::binary); // { // <- (2) zlib_stream::zip_ostream Out_Zip(Out, std::ios::out, true); for(int i = 0; i < LoopCnt; ++i) { memcpy(WorkBuffer, CheckBuffer, BufferSize); Out_Zip.write(WorkBuffer, BufferSize); } Out_Zip.zflush(); // } // <- (2) Out.close(); } { std::ifstream In("c:\\test.bin", std::ios::in | std::ios::binary); { zlib_stream::zip_istream In_Zip(In); for(int i = 0; i < LoopCnt; ++i) { char WorkBuffer[BufferSize]; memcpy(WorkBuffer, Zero, BufferSize); In_Zip.read(WorkBuffer, BufferSize); assert(In_Zip.good()); for(int j = 0; j < BufferSize; ++j) { assert(WorkBuffer[j] == (char)(j + 1)); // <- (1) } } } In.close(); } </sample> Thanks.
|
|
|
|
|

|
These wrappers look really useful, thanks for providing them!
Do you have any plans to add support for the seekg and tellg to zipstream in the future? This would really widen the applicability of the wrappers.
Thanks again,
-greg
|
|
|
|

|
after finally get the demo code running... out of the following test functions, i got following results as marked in the right side of each functions.
zlib_stream::test_buffer_to_buffer();------------>OK
zlib_stream::test_wbuffer_to_wbuffer();------------>OK
zlib_stream::test_string_string();------------>OK
zlib_stream::test_wstring_wstring();------------>OK
zlib_stream::test_file_file(false);------------>NOT OK...
zlib_stream::test_file_file(true);------------>NOT OK...
In test_file_file(), compressing seems to be working with compressed output file generated... but when unzipping the zipped file, the size of the unzipped file is 0, i.e. it is not reading data from the zipped file though i can see that zipped file is not empty...
plz help...
lost in templates
|
|
|
|

|
Hi,
I try to compress a buffer > to the default_buffer_size defined in zipstream.hpp ...
If you increase the constant : const size_t n=
in the test : zlib_stream::test_buffer_to_buffer(),
it fails !
Do you have a solution to compress huge memory buffer without risking a 'stack overflaw'
when increasing the default_buffer_size ?
I'm particularly interested by compressing huge in-memory buffer !
Thank you again to provide this well designed code to the dev' community.
Silver
|
|
|
|

|
Hi,
I try to put in place an 'in house' solution using IIS 'standard' Compression on server Side and zlib decompression on the client side.
I'm not running IE, so I don't use URLMon and I try to uncompress data received from my IIS Server using
Wininet directly connected to the zlib wrapper ...
Currently, I can successfully decompress small buffers < 30K, but big buffers causes the gzread routine to fail (returns -1).
If you have any Idea, it will be a great help for me.
I'm getting frustrated with this !
Regards
-Silver-
|
|
|
|

|
Hello All... Sorry for the novice question, but i get an error while compiling the library with VC6:
in zipstream.ipp : int_type is not a member of basic_zipstreambuf<...>
can anybody help me? Everything worked ok with VC7, but i need to hand the project with VC6 ..
thanks!
|
|
|
|

|
I am also interested in a VC6 compatible version. So if there's anyone, please reply if you have adapted the source to compile on VC6.
|
|
|
|

|
Ok, after doing some changes and improvements, I am now able to compile ZipStream with VC6 SP5. If anyone is interested in my modifications, let me know.
|
|
|
|
|

|
Hi,
will you update the article for compiling it with VC6? Or at least post an answer how to compile it...
Regards,
Patrik
|
|
|
|

|
Here's the how-to:
- Move all the problematic method back inside the class declaration (ipp->hpp),
- there seems to be some problems with std::min, so replace it by your own min template function
That's it
I'll post an update soon.
|
|
|
|

|
After doing all in one file and adding some typedefs for int_size and so on everythink works as expected.
Thanks for the help!
Patrik
|
|
|
|

|
PS:
How about adding an "ifstream" and "ofstream" like class?
Patrik
|
|
|
|

|
Hm,
too fast, I've got an error when using zflush():
basic_zip_ostream& zflush(void)
{
std::basic_ostream::flush();
basic_zip_streambuf::flush();
return *this;
}
d:\projekte\3d\imtk\tkim_kernel\zipstream.h(483) : warning C4355: this' : wird in Initialisierungslisten für Basisklasse verwendet
d:\projekte\3d\imtk\tkim_kernel\zipstream.h(474) : Bei der Kompilierung der Member-Funktion '__thiscall basic_zip_ostream >::basic_zip_ostream >(class std::basic_ostream > &,bool,int,enum EStrategy,int,int,unsigned int)' der Klassenvorlage
d:\projekte\3d\imtk\tkim_kernel\zipstream.h(501) : error C2352: 'std::basic_ostream >::flush' : Unzulaessiger Aufruf einer nicht statischen Member-Funktion
c:\programme\microsoft visual studio\vc98\include\ostream(253) : Siehe Deklaration von 'flush'
d:\projekte\3d\imtk\tkim_kernel\zipstream.h(500) : Bei der Kompilierung der Member-Funktion 'class basic_zip_ostream > &__thiscall basic_zip_ostream >::zflush(void)' der K
lassenvorlage
Sorry for the german error messages,
Patrik
|
|
|
|

|
Did you to move this one in the class as well ? Sorry my german is really bad can't understand the errors.
Jonathan de Halleux - My Blog
|
|
|
|

|
coule you send this version to me please
|
|
|
|

|
Hi,
I need it too. Please
Thank you.
--> Tigerauge@myrealbox.com
Chris
|
|
|
|

|
Hi Vatiila,
Could you please send me the modifications required to compile this sample on VC6.
Thanks in advance,
kamaralikhan@yahoo.com
|
|
|
|

|
yes please i need the version too!!
nayyyyyyyyyyy
|
|
|
|

|
Due to the ongoing interest in my modifications, and the lack of an update to the article, I've made the code available for download here.
Changes:
- Renamed ".hpp" to ".h" (for my purposes only).
- Incorportated some bug-fixes found in the discussion board for the article (compressed gzip header, etc.).
- Removed dependency on "zutil.h" as per zlib recommendations (by copying necessary stuff, platform ids).
- Modifications for VC6 compatibility (mainly scope resolution for types).
Notes:
- I haven't tested the bzip2 streams.
- The original test cases are failing for some reason.
I've incorporated the zlib-version into my project and it seems to work well. BUT, no warranties --- test thoroughly!
|
|
|
|

|
A MILLION THANKS!!!
|
|
|
|

|
Hi, Could you share the file at some other location. I am not able to download it.
Thanks
NR
|
|
|
|

|
Hi Vattila,
i got the same errors like you when compiling the
zipstream.hpp / zipstream.ipp files!
Could you please mail me your "improvements" to make
it work?
Thx,
Arnd
|
|
|
|

|
Hi Vattila,
I got the same problems like you compiling zipstream.hpp/
zipstream.ipp on VC++6.0!
Could you please send me your "improvements" to make the
compilation work?
Thx Arnd
|
|
|
|

|
i downloaded zipstream_demo.zip and tried to run the test. i noticed some failures so after digging around a bit, i noticed that basic_zip_ostream c'tor had an extra unneeded param (i.e. open_mode). also in test_crc(), you aren't calling zipOut.zflush().
i was wondering if what's up there right now is a little bit outdated?
--phil
|
|
|
|

|
When using this class to output to a compressed file using something like:
ofstream ofs("foo.zip", ios::out);
zip_ostream zipofs(ofs, ios::out, true);
zipofs << "testing..." << endl;
zipofs << "testing2..." << endl;
the compression doesn't appear to work.
However, changing the last two lines to:
zipofs << "testing...\n";
zipofs << "testing2...\n";
does.
I'm guessing that this is due to endl flushing the output stream. Has anybody else come across this problem.
(This is with VC++.NET 1.1)
|
|
|
|

|
I'm a bit out of this problem now. Could you send me your full project ? (dehalleux@pelikhan.com)
Jonathan de Halleux.
www.dotnetwiki.org
|
|
|
|

|
i'm trying to compress large buffers (around 10 MEGA) but its going too slow.(17 sec)
do you have any suggestions?
how do i change the compression level?
thanks
ishay
eg:
void test_file_file()
{
long gl_n = 7000000;
bzip2_ostream *m_pfzipper = NULL;
bzip2_istream *m_pfunzipper = NULL;
ifstream m_ifstream_;
ofstream m_ofstream_;
// create some test values
char* in_buff = NULL;
char* out_buff = NULL;
in_buff = new char[gl_n];
out_buff = new char[gl_n];
for(long i = 0; i < gl_n-1 ; i++)
in_buff[i] = static_cast(48+i%48);
// creating the target zip string, could be a fstream
m_ofstream_.open("test.zip",ios::out | ios::binary );
if (!m_ofstream_.is_open())
{
cerr<<"err"<<endl;
}
else
{
cerr<<"opend"<<endl;
}
// creating the zip layer
m_pfzipper = new bzip2_ostream(m_ofstream_);
m_pfzipper->write(in_buff,gl_n);
cerr<<"finished "<<gl_n<<endl;
cerr<<"flaushing "<<endl;
// zip ostream needs special flushing...
m_pfzipper->zflush();
cerr<<"flaushing finished"<<endl;
m_ofstream_.close();
delete m_pfzipper;
// create a stream on zip string
m_ifstream_.open("test.zip", ios::in | ios::binary);
if (!m_ifstream_.is_open())
{
cerr<<"Could not open file ishay.zip"<<endl;
}
// create unzipper istream
m_pfunzipper = new bzip2_istream( m_ifstream_);
// unzipping
m_pfunzipper->read(out_buff,gl_n);
// ouputing results
cerr<<"tests file-to-file :"<<endl
<<"------------------------------"<<endl<<endl;
}
|
|
|
|

|
I try to zip a big text file and unzip it again, the result is not the same size as the original. Here is the code I use:
ifstream ifstream_("c:\\test.CSV",ios::in| ios::binary );//CSV file 5,357 KB
ofstream ofstream_("c:\\GZIPtest.gz",ios::out | ios::binary );
zip_ostream fzipper(ofstream_,add_gzip_header);
char c;
while (ifstream_.get(c))
fzipper << c;
fzipper.zflush();
ifstream ifstream_1;
ifstream_1.open("C:\\GZIPtest.gz", ios::in | ios::binary);
// create unzipper istream
zip_istream funzipper( ifstream_1);
ofstream ofs;
ofs.open("C:\\GZIPTest.csv", ios::out | ios::binary);
// unzipping
while (funzipper.get(c))
ofs << c;
the result file: GZIPTest.csv = 5,327 KB, about 30 KB short of the original, could you help on this?
Thanks in advance!
Yong Kie Yong
|
|
|
|

|
Could you try this:
ifstream ifstream_("c:\\test.CSV",ios::in| ios::binary );ofstream ofstream_("c:\\GZIPtest.gz",ios::out | ios::binary );
{
zip_ostream fzipper(ofstream_,add_gzip_header);
fzipper << ifstream.rdbuf();
}
ifstream ifstream_1;
ifstream_1.open("C:\\GZIPtest.gz", ios::in | ios::binary);
zip_istream funzipper( ifstream_1);
ofstream ofs;
ofs.open("C:\\GZIPTest.csv", ios::out | ios::binary);
ofs << funzipper.rdbuf();
|
|
|
|

|
It is still not working (I insert a fzipper.zflush() following fzipper << ifstream.rdbuff()), I observe that there is always a 30 KB missing on the uncompressed file. Could it be a bug?
|
|
|
|

|
Could you find a smaller data set that has the problem and email it to me ?
Jonathan de Halleux.
www.dotnetwiki.org
|
|
|
|

|
Jonathan,
It seems that it always happens on big data set, my data is CSV file exported from Excel, I believe you will be able to generate the same data by populating the Excel table with dummy data and export it out as CSV, just make the data something like 5 M and you will see the problem
Thanks.
Yongki C. Andyka Jong
Don't know much < I, don't care much > I, while I am here ... just be happy
|
|
|
|

|
Trying to compile a test application with VC6 SP5 and STLport 4.5.3 (compiled with it's own iostream) and I keep getting this error : zipstream.hpp(313) : error C2660: basic_ostream<char,class _STL::char_traits<char> >::basic_ostream<char,class _STL::char_traits<char> > : function does not take 2 parameters zipstream.hpp(299) : while compiling class-template member function __thiscall zlib_stream::basic_zip_ostream<char, class _STL::char_traits<char> >::zlib_stream::basic_zip_ostream<char,class _STL::char_traits<char> > (class _STL::basic_ostream<char,class _STL::char_traits<char> > &, int, bool, unsigned int, enum zlib_stream::EStrategy, unsigned int, unsigned int, unsigned int)' So the problem is with basic_ostream. In STLport, it doesn't have any parameters... Can anybody help me out ?
|
|
|
|

|
I'm not familiar with STLPot. Basically, there's a lot to change but with some replace all you should get out of trouble.
Tell me if making the changes troubles you...
|
|
|
|

|
Hi,
You're referencing in bzip2_stream_test.cpp but the file is not included in the project.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
STL compliant, stream-to-stream, zlib and bzip2 wrapper with wide char support.
| Type | Article |
| Licence | |
| First Posted | 1 Jul 2003 |
| Views | 217,043 |
| Bookmarked | 93 times |
|
|