ruby-zip problem

  • Thread starter Takashi & Kayoko Sano
  • Start date
T

Takashi & Kayoko Sano

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
 
J

James

Takashi said:
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
 
T

Thomas Sondergaard

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,142
Messages
2,570,818
Members
47,362
Latest member
eitamoro

Latest Threads

Top