Menu

#23 problem creating a zip containing a binary

open
nobody
None
5
2012-07-18
2007-05-19
Chas12345
No

I'm trying to create a zip file that contains a dir with binary files inside of it.

used this as a point of departure...
with src is a dir containig 2 binaries (.mp3 files)

<--zip_binary.rb---->

require 'rubygems'
require 'zip/zipfilesystem'
require 'FileUtils'

stuff = FileUtils.cp_r 'src/.', 'order' #this copies the files fine...

Zip::ZipFile.open('my.zip', Zip::ZipFile::CREATE) do |zip|
zip.file.open('my.zip', 'w') { |f1| f1 << stuff }
end

<----end zip_binary.rb---->

This results in an empty zip file "stuff.zip" which contains a dir named "order 2".

I've also tried "wb' unsuccessfully and "a" and "a+" with the errors below (respectively)

generally i get these errors
/usr/local/lib/ruby/gems/1.8/gems/rubyzip-0.9.1/lib/zip/zipfilesystem.rb:234:in open': openmode 'wb not supported (StandardError) from t.rb:9 from /usr/local/lib/ruby/gems/1.8/gems/rubyzip-0.9.1/lib/zip/zip.rb:1382:inopen'
from t.rb:8

Discussion

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.