Ruby-zip problem

Hi folks,

I’m now playing with ruby-zip. I can make it work right for
decompression of zip files, but somehow not for compression.
It actually creates a zip file, but it’s corrupted. Could anyone
point me to the right direction? I’m a novice programmer and ruby-zip
is scarcely documented, so maybe I’m not aware of things that
require attention.

The sample script is shown below.

require ‘zip/zip’

Zip::ZipFile.open(“test.sxw”) {|zf|
zf.replace(“content.xml”, “content_new.xml”)
}

What I want to do is, opening a OpenOffice.org Writer file, which
is actually a zip file containing 5 files and 1 folder with 1 file,
and replacing the document’s content file, which is encoded in UTF-8,
with a new one. The strange thing is when the resultant zip file is
decompressed, the replaced file is decompressed fine, but the rest
of files are corrupted.

BTW, I’m doing this on Windows XP and arton’s ActiveScriptRuby
1.8.0.5.

Thanks in advance,

Takashi Sano

Takashi & Kayoko Sano wrote:

Hi folks,

I’m now playing with ruby-zip. I can make it work right for
decompression of zip files, but somehow not for compression.
It actually creates a zip file, but it’s corrupted. Could anyone
point me to the right direction? I’m a novice programmer and ruby-zip
is scarcely documented, so maybe I’m not aware of things that
require attention.

The sample script is shown below.

require ‘zip/zip’

Zip::ZipFile.open(“test.sxw”) {|zf|
zf.replace(“content.xml”, “content_new.xml”)
}

I’ve encountered the same issue doing the same thing.

You may be interested in a new RubyForge project, OOo4R, which intends
to offer a reasonably compleate, pure-Ruby API for manipulating
OpenOffice documents.

http://ooo4r.rubyforge.org/

(There’s no code there as of yet. I have to sort out some ideas I tried
out recently and then upload the code classes.)

The project was born from Daniel Carrera’s OOoExtract program.
http://www.math.umd.edu/~dcarrera/openoffice/tools/ooo_extract.html

If you get an answer to your problem, please post it to ruby-talk. If I
figure it out I’ll do the same.

James

require ‘zip/zip’

Zip::ZipFile.open(“test.sxw”) {|zf|
zf.replace(“content.xml”, “content_new.xml”)
}

What I want to do is, opening a OpenOffice.org Writer file, which
is actually a zip file containing 5 files and 1 folder with 1 file,
and replacing the document’s content file, which is encoded in UTF-8,
with a new one. The strange thing is when the resultant zip file is
decompressed, the replaced file is decompressed fine, but the rest
of files are corrupted.

Oups, you found a bug. A fix has been committed to CVS.

Cheers,

Thomas

Thomas Sondergaard wrote:

Oups, you found a bug. A fix has been committed to CVS.

You’re my hereo!

Thanks,

James

···

Cheers,

Thomas