[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rubyzip problem / question

Dan

10/17/2006 4:46:00 PM

Hi,

I'm fairly new to ruby and am trying to use the rubyzip library (I
downloaded the latest gem) to change a directory name in a zipped file.
The code below seems to work (i.e. the directory names show as changed
in winzip), but I get "crc errors" when I try to actually decompress
the file. I'd really like to avoid the overhead of unzipping and
re-zipping each file. Any suggestions would be greatly appreciated!

require 'zip/zip'

target = "test.zip"

Zip::ZipFile.open(target) do |zipfile|
zipfile.each do |e|
if !e.directory? and e.to_s.include? "olddir"
zipfile.rename(e.to_s, e.to_s.gsub("olddir", "newdir"))
end
end
end

- Dan

1 Answer

Jérôme Loyet

12/14/2006 8:34:00 AM

0

> Hi,

Hello

>
> I'm fairly new to ruby and am trying to use the rubyzip library (I
> downloaded the latest gem) to change a directory name in a zipped file.
> The code below seems to work (i.e. the directory names show as changed
> in winzip), but I get "crc errors" when I try to actually decompress
> the file. I'd really like to avoid the overhead of unzipping and
> re-zipping each file. Any suggestions would be greatly appreciated!
>
> require 'zip/zip'
>
> target = "test.zip"
>
> Zip::ZipFile.open(target) do |zipfile|
> zipfile.each do |e|
> if !e.directory? and e.to_s.include? "olddir"
> zipfile.rename(e.to_s, e.to_s.gsub("olddir", "newdir"))
> end
> end
> end
>

I've got exactly the same problem. I sent the information to the
developers of rubyzip and they created a bug in the tracker.

Just in case, has someone found a solution of that ? Maybe an unknown
patch ? :)
Thanks in advance,
Regards,
++ Jerome

> - Dan