#14340: wxTarOutputStream cannot write into wxZlibOutputStream

9 views
Skip to first unread message

wxTrac

unread,
May 26, 2012, 7:47:55 PM5/26/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14340>

#14340: wxTarOutputStream cannot write into wxZlibOutputStream
--------------------+-------------------------------------------------------
Reporter: ardi | Owner:
Type: defect | Status: new
Priority: normal | Milestone:
Component: base | Version: 2.9-svn
Keywords: | Blockedby:
Patch: 0 | Blocking:
--------------------+-------------------------------------------------------
When the wxTar* and wxZlib* classes were first announced, it was told you
could create a tar and compress it in a single operation. However, as
explained in the following forum thread, it's not possible to do so:

http://forums.wxwidgets.org/viewtopic.php?f=27&t=21735

The problem appears to be that wxTarOutputStream requires its output to be
a seekable stream. However, it seems this requirement didn't exist when
these classes were initially implemented.

Not being able to create a tar and compress it on the fly is an annoyance
because it requires to temporally store the whole tar file on a memory
stream, which can be quite memory consuming.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14340>

wxTrac

unread,
May 27, 2012, 7:45:07 AM5/27/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:1>

#14340: wxTarOutputStream cannot write into wxZlibOutputStream
-----------------------------+----------------------------------------------
Reporter: ardi | Owner:
Type: defect | Status: new
Priority: low | Milestone:
Component: base | Version: 2.9-svn
Keywords: stream tar seek | Blockedby:
Patch: 0 | Blocking:
-----------------------------+----------------------------------------------
Changes (by vadz):

* cc: mweth (added)
* keywords: => stream tar seek
* priority: normal => low


Comment:

This is indeed somewhat unexpected, I thought this was supposed to work
too.

Does anybody know if this can be fixed or if it's a fundamental problem
that we just need to document?


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:1>

wxTrac

unread,
May 28, 2012, 12:56:03 PM5/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:2>

#14340: wxTarOutputStream cannot write into wxZlibOutputStream
-----------------------------+----------------------------------------------
Reporter: ardi | Owner:
Type: defect | Status: new
Priority: low | Milestone:
Component: base | Version: 2.9-svn
Keywords: stream tar seek | Blockedby:
Patch: 0 | Blocking:
-----------------------------+----------------------------------------------

Comment(by mweth):

Hi,

You should just need to call wxTarEntry::SetSize() when you add each file.
It's mentioned in the docs:
http://docs.wxwidgets.org/2.8/wx_wxtarentry.html#wxtarentrysize

It's necessary because the size of the file is stored in the tar's header
before the data. If you don't know the size of the data in advance then
you'll have to write it to a temporary file like you're doing, and the tar
stream will seek back and fix up the header when you close each entry.


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:2>

wxTrac

unread,
May 28, 2012, 3:32:36 PM5/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:3>

#14340: Document that wxTarEntry::SetSize() must be called when using unseekable
streams.
-----------------------------+----------------------------------------------
Reporter: ardi | Owner:
Type: defect | Status: confirmed
Priority: low | Milestone:
Component: documentation | Version: 2.9-svn
Keywords: stream tar seek | Blockedby:
Patch: 0 | Blocking:
-----------------------------+----------------------------------------------
Changes (by vadz):

* status: new => confirmed
* component: base => documentation


Comment:

Ah, thanks Mike, sorry for not remembering about this.

I guess documentation could be improved to mention this method somewhere
in the overview but I don't really know these classes well so I'm leaving
this for somebody else to do.

Perhaps the code could also be modified with an assert saying to call
`SetSize()` if the output stream is unseekable?


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:3>

wxTrac

unread,
May 28, 2012, 4:14:51 PM5/28/12
to wx-...@googlegroups.com
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:4>

#14340: Document that wxTarEntry::SetSize() must be called when using unseekable
streams.
-----------------------------+----------------------------------------------
Reporter: ardi | Owner:
Type: defect | Status: confirmed
Priority: low | Milestone:
Component: documentation | Version: 2.9-svn
Keywords: stream tar seek | Blockedby:
Patch: 0 | Blocking:
-----------------------------+----------------------------------------------

Comment(by ardi):

I can confirm that it now works if I call wxTarEntry::SetSize() as said.
(well, actually, I'm not calling SetSize explicitly, but
calling PutNextEntry() specifying the entry size in the third argument).

I also believe the docs could say this more clearly, perhaps even
including a short code snippet (just the snippet from the above forum
thread would suffice, with a modified PutNextEntry() setting the size).

Thanks a lot, it's great to pack and compress on the fly!! I'm happy today
:-)

ardi


--
Ticket URL: <http://trac.wxwidgets.org/ticket/14340#comment:4>
Reply all
Reply to author
Forward
0 new messages