【发布时间】:2011-02-10 11:06:39
【问题描述】:
我在 Windows 上使用 rubyzip 来压缩目录。 当我解压缩档案时,有些文件比原来的要小。
压缩应该是无损操作,所以我想知道为什么会这样。
这是我正在使用的代码:
require 'rubygems'
require 'find'
require 'zip/zip'
output = "c:/temp/test.zip"
zos = Zip::ZipOutputStream.new(output)
path = "C:/temp/profile"
::Find.find(path) do |file|
next if File.directory?(file)
entry = file.sub("#{path}/", '')
zos.put_next_entry(entry)
zos << File.read(file)
end
zos.close
有问题的特定文件来自 firefox 配置文件。 cert8.db 和 key3.db
在 linux 上的 jruby 下使用相同的文件运行相同的代码可以按预期工作 - 所有文件的大小都相同。
任何想法为什么这是 Windows 上的问题?
【问题讨论】: