wxZipOutputStream Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
asadilan
Earned some good credits
Earned some good credits
Posts: 147
Joined: Tue Jul 27, 2010 10:42 pm

wxZipOutputStream

Post by asadilan » Tue Aug 20, 2013 8:58 pm

Hi All,

I am trying to zip 1 file. the problem i am having is after zipping, when i tried to open it with winrar or explorer, it always tells me file is corrupted. the size looks correct.
1 thing i notice is that the crc is 0.
any advice?
i am on 2.8.12
below is my code.

Thanks in Advance

Code: Select all

 wxFileName zipFileName = filename;
                zipFileName.SetExt("zip");

                wxFFileOutputStream zipout(zipFileName.GetFullPath());
                wxZipOutputStream zip(zipout);

                wxFFileInputStream dataReader(filename.GetFullPath());
                wxZipEntry entry( filename.GetFullName());
                entry.SetCrc(crc);
                
                long crcEntry = entry.GetCrc();// ReadLocal(dataReader,wxConvUTF8);
                if (crcEntry == crc)
                {
                    wxMessageBox("same crc");
                }

                if (dataReader.IsOk())
                {
                    zip.PutNextEntry(filename.GetFullName());
                    zip.Write(dataReader);
                    //dataReader->Read(zip);
                    //zip.Write(dataReader);
                    /*while (!dataReader->Eof())
                    {
                        *dataReader>>zip ;
                    }*/
                }
				
                zip.Close();


User avatar
doublemax
Moderator
Moderator
Posts: 14782
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxZipOutputStream

Post by doublemax » Tue Aug 20, 2013 9:46 pm

I'm not sure you're supposed to call SetCrc() yourself. Did you try without that call?
Use the source, Luke!

catalin
Moderator
Moderator
Posts: 1562
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: wxZipOutputStream

Post by catalin » Tue Aug 20, 2013 9:59 pm

How's this:

Code: Select all

                wxFFileOutputStream zipout(zipFileName.GetFullPath());
                wxZipOutputStream zip(zipout);

                wxFFileInputStream dataReader(filename.GetFullPath());

                if (dataReader.IsOk())
                {
                    zip.PutNextEntry(filename.GetFullName());
                    zip.Write(dataReader);
                }
            
                zip.Close();

Post Reply