我正在尝试找出一种使用 rubyzip 压缩文件的方法。我回滚到版本 0.9.9 因为新版本不起作用。下面是我试图测试它的代码
require 'rubygems'
require 'zip/zip'
folder = "/temp"
input_filenames = ['COKE.csv', 'GM.csv', 'GOOG.csv']
zipfile_name = "/archive.zip"
Zip::ZipFile.open(zipfile_name, Zip::ZipFile::CREATE) do |zipfile|
input_filenames.each do |filename|
# Two arguments:
# - The name of the file as it will appear in the archive
# - The original file, including the path to find it
zipfile.add("archive", folder + '/' + filename)
end
zipfile.get_output_stream("myFile") { |os| os.write "myFile contains just this" }
end
我收到一个错误,Errno::EACCES: Permission denied - /archive.zip20140716-17537-1t9f1pd。我想这与磁盘权限有关吗?我该如何解决?