Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
creating a zip file using rubyzip
Raimon Fs
5/21/2009 6:29:00 PM
I'm trying to create a zip file, but I'm getting an error saying the
file doesn't exist, but it exists, as shown in the code.
Any clues ?
I think the permissions are OK, as everyboday can read it ...
maybe there's another way to create a zip file ...
thanks,
r.
require "rubygems"
require 'zip/zip'
require 'zip/zipfilesystem'
file_path =
"/Users/montx/Documents/Ruby/codi/scanns/download/bs_promotors/masivo_prestamos_20090521.txt"
file_zip="/Users/montx/Documents/Ruby/codi/scanns/download/bs_promotors/masivo_prestamos_20090521.zip"
EXAMPLE_ZIP=file_zip
Zip::ZipFile.open(EXAMPLE_ZIP, Zip::ZipFile::CREATE) { |zf|
puts "File ready to zip" if File.exists?(file_path)
puts zf.file.read(file_path)
}
output:
File ready to zip
Errno::ENOENT: No such file or directory -
Users/montx/Documents/Ruby/codi/scanns/download/bs_promotors/masivo_prestamos_20090521.txt
method get_entry in zip.rb at line 1515
method get_input_stream in zip.rb at line 1411
method read in zip.rb at line 1435
method read in zipfilesystem.rb at line 562
method read in zipfilesystem.rb at line 383
at top level in untitled at line 16
method open in zip.rb at line 1382
at top level in untitled at line 11
copy output
Program exited with code #1 after 0.16 seconds.
--
Posted via
http://www.ruby-...
.
2 Answers
Brian Candler
5/21/2009 7:50:00 PM
0
Raimon Fs wrote:
> puts zf.file.read(file_path)
This is asking to read a file out of the zip file - and as it says,
there is no such file, as you've only just created the empty zip file.
--
Posted via
http://www.ruby-...
.
Raimon Fs
5/21/2009 9:31:00 PM
0
Brian Candler wrote:
> Raimon Fs wrote:
>> puts zf.file.read(file_path)
>
> This is asking to read a file out of the zip file - and as it says,
> there is no such file, as you've only just created the empty zip file.
yes, you're right, I thought it was reading the file and at the same
time adding it ...
In the documentation I have found .add
add(entry, srcPath, &continueOnExistsProc)
and now works ....
thanks,
r.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
creating a zip file using rubyzip
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password