Zip files preserving timestamps


I’m using Ruby 1.8.7 and the gem ‘zip’ (2.0.2) to zip up an array of
filenames found in a directory: + ‘.zip’, Zip::ZipFile::CREATE) do |zipfile|
files.each do |f|
zipfile.add(f, File.join(dir, f))

  • which works fine.

However, the zip archive holds files with timestamps of the time the zip
file was created, rather than preserving the original timestamps of the
files, which is what I am after.

I’ve had a look at the gem docs but can’t see anything obvious about
setting/preserving timestamps.

Can anyone offer assistance? Is rubyzip a better option (although I’m
sometimes deploying on 1.9 so prefer zip)