From 1d32d45944e71ae586152e514874e1caaa287b56 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 23 Dec 2009 02:19:16 -0600 Subject: [PATCH] Upgrade Vendored rubyzip to Version 0.9.3 --- .../{rubyzip-0.9.1 => rubyzip}/ChangeLog | 0 .../plugins/{rubyzip-0.9.1 => rubyzip}/NEWS | 13 ++ .../plugins/{rubyzip-0.9.1 => rubyzip}/README | 2 +- .../{rubyzip-0.9.1 => rubyzip}/Rakefile | 2 +- .../plugins/{rubyzip-0.9.1 => rubyzip}/TODO | 0 .../{rubyzip-0.9.1 => rubyzip}/install.rb | 7 +- .../lib/zip/ioextras.rb | 12 +- .../lib/zip/stdrubyext.rb | 0 .../lib/zip/tempfile_bugfixed.rb | 0 .../{rubyzip-0.9.1 => rubyzip}/lib/zip/zip.rb | 55 +++++-- .../lib/zip/zipfilesystem.rb | 1 + .../lib/zip/ziprequire.rb | 0 .../samples/example.rb | 0 .../samples/example_filesystem.rb | 1 - .../samples/gtkRubyzip.rb | 0 .../samples/qtzip.rb | 0 .../samples/write_simple.rb | 0 vendor/plugins/rubyzip/samples/zipdialogui.ui | 150 ++++++++++++++++++ .../samples/zipfind.rb | 0 .../test/alltests.rb | 0 .../test/data/file1.txt | 0 .../test/data/file1.txt.deflatedData | Bin .../test/data/file2.txt | 0 .../test/data/notzippedruby.rb | 0 .../test/data/rubycode.zip | Bin .../test/data/rubycode2.zip | Bin .../test/data/testDirectory.bin | Bin .../test/data/zipWithDirs.zip | Bin .../test/gentestfiles.rb | 0 .../test/ioextrastest.rb | 0 .../test/stdrubyexttest.rb | 0 .../test/zipfilesystemtest.rb | 18 ++- .../test/ziprequiretest.rb | 0 .../test/ziptest.rb | 22 +-- 34 files changed, 247 insertions(+), 36 deletions(-) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/ChangeLog (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/NEWS (90%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/README (99%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/Rakefile (95%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/TODO (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/install.rb (69%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/ioextras.rb (92%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/stdrubyext.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/tempfile_bugfixed.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/zip.rb (97%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/zipfilesystem.rb (99%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/lib/zip/ziprequire.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/example.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/example_filesystem.rb (98%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/gtkRubyzip.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/qtzip.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/write_simple.rb (100%) create mode 100644 vendor/plugins/rubyzip/samples/zipdialogui.ui rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/samples/zipfind.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/alltests.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/file1.txt (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/file1.txt.deflatedData (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/file2.txt (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/notzippedruby.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/rubycode.zip (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/rubycode2.zip (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/testDirectory.bin (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/data/zipWithDirs.zip (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/gentestfiles.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/ioextrastest.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/stdrubyexttest.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/zipfilesystemtest.rb (97%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/ziprequiretest.rb (100%) rename vendor/plugins/{rubyzip-0.9.1 => rubyzip}/test/ziptest.rb (98%) diff --git a/vendor/plugins/rubyzip-0.9.1/ChangeLog b/vendor/plugins/rubyzip/ChangeLog similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/ChangeLog rename to vendor/plugins/rubyzip/ChangeLog diff --git a/vendor/plugins/rubyzip-0.9.1/NEWS b/vendor/plugins/rubyzip/NEWS similarity index 90% rename from vendor/plugins/rubyzip-0.9.1/NEWS rename to vendor/plugins/rubyzip/NEWS index 0f46f727..146be46a 100644 --- a/vendor/plugins/rubyzip-0.9.1/NEWS +++ b/vendor/plugins/rubyzip/NEWS @@ -1,3 +1,16 @@ += Version 0.9.3 + +Fixed: Added ZipEntry::name_encoding which retrieves the character +encoding of the name and comment of the entry. Also added convenience +methods ZipEntry::name_in(enc) and ZipEntry::comment_in(enc) for +getting zip entry names and comments in a specified character +encoding. + += Version 0.9.2 + +Fixed: Renaming an entry failed if the entry's new name was a +different length than its old name. (Diego Barros) + = Version 0.9.1 Added symlink support and support for unix file permissions. Reduced diff --git a/vendor/plugins/rubyzip-0.9.1/README b/vendor/plugins/rubyzip/README similarity index 99% rename from vendor/plugins/rubyzip-0.9.1/README rename to vendor/plugins/rubyzip/README index 81ec4c5d..79546e0b 100644 --- a/vendor/plugins/rubyzip-0.9.1/README +++ b/vendor/plugins/rubyzip/README @@ -69,4 +69,4 @@ Thomas Sondergaard (thomas at sondergaard.cc) Technorama Ltd. (oss-ruby-zip at technorama.net) -extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org) +extra-field support contributed by Tatsuki Sugiura (sugi at nemui.org) \ No newline at end of file diff --git a/vendor/plugins/rubyzip-0.9.1/Rakefile b/vendor/plugins/rubyzip/Rakefile similarity index 95% rename from vendor/plugins/rubyzip-0.9.1/Rakefile rename to vendor/plugins/rubyzip/Rakefile index c6581cf6..23144f32 100755 --- a/vendor/plugins/rubyzip-0.9.1/Rakefile +++ b/vendor/plugins/rubyzip/Rakefile @@ -62,7 +62,7 @@ end Rake::RDocTask.new do |rd| rd.main = "README" rd.rdoc_files.add %W{ lib/zip/*.rb README NEWS TODO ChangeLog } - rd.options << "--title 'rubyzip documentation' --webcvs http://cvs.sourceforge.net/viewcvs.py/rubyzip/rubyzip/" + rd.options << "-t 'rubyzip documentation' --webcvs http://cvs.sourceforge.net/viewcvs.py/rubyzip/rubyzip/" # rd.options << "--all" end diff --git a/vendor/plugins/rubyzip-0.9.1/TODO b/vendor/plugins/rubyzip/TODO similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/TODO rename to vendor/plugins/rubyzip/TODO diff --git a/vendor/plugins/rubyzip-0.9.1/install.rb b/vendor/plugins/rubyzip/install.rb similarity index 69% rename from vendor/plugins/rubyzip-0.9.1/install.rb rename to vendor/plugins/rubyzip/install.rb index 405e2b0b..7a156bd1 100755 --- a/vendor/plugins/rubyzip-0.9.1/install.rb +++ b/vendor/plugins/rubyzip/install.rb @@ -4,19 +4,20 @@ $VERBOSE = true require 'rbconfig' require 'find' -require 'ftools' +require 'fileutils' include Config files = %w{ stdrubyext.rb ioextras.rb zip.rb zipfilesystem.rb ziprequire.rb tempfile_bugfixed.rb } INSTALL_DIR = File.join(CONFIG["sitelibdir"], "zip") -File.makedirs(INSTALL_DIR) +FileUtils.makedirs(INSTALL_DIR) SOURCE_DIR = File.join(File.dirname($0), "lib/zip") files.each { |filename| installPath = File.join(INSTALL_DIR, filename) - File::install(File.join(SOURCE_DIR, filename), installPath, 0644, true) + FileUtils::install(File.join(SOURCE_DIR, filename), installPath, 0644, + :verbose => true) } diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/ioextras.rb b/vendor/plugins/rubyzip/lib/zip/ioextras.rb similarity index 92% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/ioextras.rb rename to vendor/plugins/rubyzip/lib/zip/ioextras.rb index c458bb58..ca3877a5 100755 --- a/vendor/plugins/rubyzip-0.9.1/lib/zip/ioextras.rb +++ b/vendor/plugins/rubyzip/lib/zip/ioextras.rb @@ -1,6 +1,6 @@ module IOExtras #:nodoc: - CHUNK_SIZE = 32768 + CHUNK_SIZE = 131072 RANGE_ALL = 0..-1 @@ -9,6 +9,16 @@ module IOExtras #:nodoc: ostream.write(istream.read(CHUNK_SIZE, s)) until istream.eof? end + def self.copy_stream_n(ostream, istream, nbytes) + s = '' + toread = nbytes + while (toread > 0 && ! istream.eof?) + tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread + ostream.write(istream.read(tr, s)) + toread -= tr + end + end + # Implements kind_of? in order to pretend to be an IO object module FakeIO diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/stdrubyext.rb b/vendor/plugins/rubyzip/lib/zip/stdrubyext.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/stdrubyext.rb rename to vendor/plugins/rubyzip/lib/zip/stdrubyext.rb diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/tempfile_bugfixed.rb b/vendor/plugins/rubyzip/lib/zip/tempfile_bugfixed.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/tempfile_bugfixed.rb rename to vendor/plugins/rubyzip/lib/zip/tempfile_bugfixed.rb diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/zip.rb b/vendor/plugins/rubyzip/lib/zip/zip.rb similarity index 97% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/zip.rb rename to vendor/plugins/rubyzip/lib/zip/zip.rb index b7304783..062286a5 100755 --- a/vendor/plugins/rubyzip-0.9.1/lib/zip/zip.rb +++ b/vendor/plugins/rubyzip/lib/zip/zip.rb @@ -1,4 +1,5 @@ require 'delegate' +require 'iconv' require 'singleton' require 'tempfile' require 'fileutils' @@ -20,7 +21,7 @@ end module Zip - VERSION = '0.9.1' + VERSION = '0.9.3' RUBY_MINOR_VERSION = RUBY_VERSION.split(".")[1].to_i @@ -349,6 +350,21 @@ module Zip attr_reader :ftype, :filepath # :nodoc: + # Returns the character encoding used for name and comment + def name_encoding + (@gp_flags & 0b100000000000) != 0 ? "utf8" : "CP437//" + end + + # Returns the name in the encoding specified by enc + def name_in(enc) + Iconv.conv(enc, name_encoding, @name) + end + + # Returns the name in the encoding specified by enc + def comment_in(enc) + Iconv.conv(enc, name_encoding, @name) + end + def initialize(zipfile = "", name = "", comment = "", extra = "", compressed_size = 0, crc = 0, compression_method = ZipEntry::DEFLATED, size = 0, @@ -358,6 +374,7 @@ module Zip raise ZipEntryNameError, "Illegal ZipEntry name '#{name}', name must not start with /" end @localHeaderOffset = 0 + @local_header_size = 0 @internalFileAttributes = 1 @externalFileAttributes = 0 @version = 52 # this library's version @@ -432,7 +449,7 @@ module Zip # Returns +true+ if the entry is a symlink. def symlink? raise ZipInternalError, "current filetype is unknown: #{self.inspect}" unless @ftype - @ftype == :link + @ftype == :symlink end def name_is_directory? #:nodoc:all @@ -440,10 +457,10 @@ module Zip end def local_entry_offset #:nodoc:all - localHeaderOffset + local_header_size + localHeaderOffset + @local_header_size end - def local_header_size #:nodoc:all + def calculate_local_header_size #:nodoc:all LOCAL_ENTRY_STATIC_HEADER_LENGTH + (@name ? @name.size : 0) + (@extra ? @extra.local_size : 0) end @@ -491,7 +508,8 @@ module Zip LOCAL_ENTRY_SIGNATURE = 0x04034b50 LOCAL_ENTRY_STATIC_HEADER_LENGTH = 30 LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH = 4+4+4 - + VERSION_NEEDED_TO_EXTRACT = 10 + def read_local_entry(io) #:nodoc:all @localHeaderOffset = io.tell staticSizedFieldsBuf = io.read(LOCAL_ENTRY_STATIC_HEADER_LENGTH) @@ -516,6 +534,7 @@ module Zip raise ZipError, "Zip local header magic not found at location '#{localHeaderOffset}'" end set_time(lastModDate, lastModTime) + @name = io.read(nameLength) extra = io.read(extraLength) @@ -529,6 +548,7 @@ module Zip @extra = ZipExtraField.new(extra) end end + @local_header_size = calculate_local_header_size end def ZipEntry.read_local_entry(io) @@ -544,7 +564,7 @@ module Zip io << [LOCAL_ENTRY_SIGNATURE , - 0 , + VERSION_NEEDED_TO_EXTRACT , # version needed to extract 0 , # @gp_flags , @compression_method , @time.to_binary_dos_time , # @lastModTime , @@ -615,7 +635,7 @@ module Zip when 010 @ftype = :file when 012 - @ftype = :link + @ftype = :symlink else raise ZipInternalError, "unknown file type #{'0%o' % (@externalFileAttributes >> 28)}" end @@ -626,6 +646,7 @@ module Zip @ftype = :file end end + @local_header_size = calculate_local_header_size end def ZipEntry.read_c_dir_entry(io) #:nodoc:all @@ -662,8 +683,8 @@ module Zip # ignore setuid/setgid bits by default. honor if @restore_ownership unix_perms_mask = 01777 unix_perms_mask = 07777 if (@restore_ownership) - File::chmod(@unix_perms & unix_perms_mask, destPath) if (@restore_permissions && @unix_perms) - File::chown(@unix_uid, @unix_gid, destPath) if (@restore_ownership && @unix_uid && @unix_gid && Process::egid == 0) + FileUtils::chmod(@unix_perms & unix_perms_mask, destPath) if (@restore_permissions && @unix_perms) + FileUtils::chown(@unix_uid, @unix_gid, destPath) if (@restore_ownership && @unix_uid && @unix_gid && Process::egid == 0) # File::utimes() end end @@ -693,7 +714,7 @@ module Zip [CENTRAL_DIRECTORY_ENTRY_SIGNATURE, @version , # version of encoding software @fstype , # filesystem type - 0 , # @versionNeededToExtract , + VERSION_NEEDED_TO_EXTRACT , # @versionNeededToExtract , 0 , # @gp_flags , @compression_method , @time.to_binary_dos_time , # @lastModTime , @@ -849,7 +870,7 @@ module Zip return elsif File.exists? destPath if block_given? && yield(self, destPath) - File.rm_f destPath + FileUtils::rm_f destPath else raise ZipDestinationFileExistsError, "Cannot create directory '#{destPath}'. "+ @@ -967,10 +988,10 @@ module Zip src_pos = entry.local_entry_offset entry.write_local_entry(@outputStream) @compressor = NullCompressor.instance - @outputStream << entry.get_raw_input_stream { + entry.get_raw_input_stream { |is| is.seek(src_pos, IO::SEEK_SET) - is.read(entry.compressed_size) + IOExtras.copy_stream_n(@outputStream, is, entry.compressed_size) } @compressor = NullCompressor.instance @currentEntry = nil @@ -981,7 +1002,7 @@ module Zip return unless @currentEntry finish @currentEntry.compressed_size = @outputStream.tell - @currentEntry.localHeaderOffset - - @currentEntry.local_header_size + @currentEntry.calculate_local_header_size @currentEntry.size = @compressor.size @currentEntry.crc = @compressor.crc @currentEntry = nil @@ -1453,7 +1474,9 @@ module Zip def rename(entry, newName, &continueOnExistsProc) foundEntry = get_entry(entry) check_entry_exists(newName, continueOnExistsProc, "rename") - foundEntry.name=newName + @entrySet.delete(foundEntry) + foundEntry.name = newName + @entrySet << foundEntry end # Replaces the specified entry with the contents of srcPath (from @@ -1566,7 +1589,7 @@ module Zip tmpFilename = tmpfile.path tmpfile.close if yield tmpFilename - File.move(tmpFilename, name) + File.rename(tmpFilename, name) end end diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/zipfilesystem.rb b/vendor/plugins/rubyzip/lib/zip/zipfilesystem.rb similarity index 99% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/zipfilesystem.rb rename to vendor/plugins/rubyzip/lib/zip/zipfilesystem.rb index 3fa3748c..e3ac33e9 100755 --- a/vendor/plugins/rubyzip-0.9.1/lib/zip/zipfilesystem.rb +++ b/vendor/plugins/rubyzip/lib/zip/zipfilesystem.rb @@ -225,6 +225,7 @@ module Zip end def open(fileName, openMode = "r", &block) + openMode.gsub!("b", "") # ignore b option case openMode when "r" @mappedZip.get_input_stream(fileName, &block) diff --git a/vendor/plugins/rubyzip-0.9.1/lib/zip/ziprequire.rb b/vendor/plugins/rubyzip/lib/zip/ziprequire.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/lib/zip/ziprequire.rb rename to vendor/plugins/rubyzip/lib/zip/ziprequire.rb diff --git a/vendor/plugins/rubyzip-0.9.1/samples/example.rb b/vendor/plugins/rubyzip/samples/example.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/samples/example.rb rename to vendor/plugins/rubyzip/samples/example.rb diff --git a/vendor/plugins/rubyzip-0.9.1/samples/example_filesystem.rb b/vendor/plugins/rubyzip/samples/example_filesystem.rb similarity index 98% rename from vendor/plugins/rubyzip-0.9.1/samples/example_filesystem.rb rename to vendor/plugins/rubyzip/samples/example_filesystem.rb index 867e8d4f..0cacbd2a 100755 --- a/vendor/plugins/rubyzip-0.9.1/samples/example_filesystem.rb +++ b/vendor/plugins/rubyzip/samples/example_filesystem.rb @@ -3,7 +3,6 @@ $: << "../lib" require 'zip/zipfilesystem' -require 'ftools' EXAMPLE_ZIP = "filesystem.zip" diff --git a/vendor/plugins/rubyzip-0.9.1/samples/gtkRubyzip.rb b/vendor/plugins/rubyzip/samples/gtkRubyzip.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/samples/gtkRubyzip.rb rename to vendor/plugins/rubyzip/samples/gtkRubyzip.rb diff --git a/vendor/plugins/rubyzip-0.9.1/samples/qtzip.rb b/vendor/plugins/rubyzip/samples/qtzip.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/samples/qtzip.rb rename to vendor/plugins/rubyzip/samples/qtzip.rb diff --git a/vendor/plugins/rubyzip-0.9.1/samples/write_simple.rb b/vendor/plugins/rubyzip/samples/write_simple.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/samples/write_simple.rb rename to vendor/plugins/rubyzip/samples/write_simple.rb diff --git a/vendor/plugins/rubyzip/samples/zipdialogui.ui b/vendor/plugins/rubyzip/samples/zipdialogui.ui new file mode 100644 index 00000000..7f978500 --- /dev/null +++ b/vendor/plugins/rubyzip/samples/zipdialogui.ui @@ -0,0 +1,150 @@ + +ZipDialogUI + + + ZipDialogUI + + + + 0 + 0 + 416 + 397 + + + + Rubyzip + + + true + + + + unnamed + + + + + Entry + + + true + + + true + + + + + Size + + + true + + + true + + + + entry_list_view + + + + 150 + 200 + + + + Manual + + + Extended + + + AllColumns + + + + + layout2 + + + + unnamed + + + + add_button + + + &Add... + + + Alt+A + + + true + + + + + extract_button + + + &Extract... + + + Alt+E + + + true + + + + + Spacer1 + + + Vertical + + + Expanding + + + + 20 + 160 + + + + + + close_button + + + &Close + + + Alt+C + + + true + + + true + + + + + + + + + close_button + clicked() + ZipDialogUI + accept() + + + + diff --git a/vendor/plugins/rubyzip-0.9.1/samples/zipfind.rb b/vendor/plugins/rubyzip/samples/zipfind.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/samples/zipfind.rb rename to vendor/plugins/rubyzip/samples/zipfind.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/alltests.rb b/vendor/plugins/rubyzip/test/alltests.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/alltests.rb rename to vendor/plugins/rubyzip/test/alltests.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/file1.txt b/vendor/plugins/rubyzip/test/data/file1.txt similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/file1.txt rename to vendor/plugins/rubyzip/test/data/file1.txt diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/file1.txt.deflatedData b/vendor/plugins/rubyzip/test/data/file1.txt.deflatedData similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/file1.txt.deflatedData rename to vendor/plugins/rubyzip/test/data/file1.txt.deflatedData diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/file2.txt b/vendor/plugins/rubyzip/test/data/file2.txt similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/file2.txt rename to vendor/plugins/rubyzip/test/data/file2.txt diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/notzippedruby.rb b/vendor/plugins/rubyzip/test/data/notzippedruby.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/notzippedruby.rb rename to vendor/plugins/rubyzip/test/data/notzippedruby.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/rubycode.zip b/vendor/plugins/rubyzip/test/data/rubycode.zip similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/rubycode.zip rename to vendor/plugins/rubyzip/test/data/rubycode.zip diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/rubycode2.zip b/vendor/plugins/rubyzip/test/data/rubycode2.zip similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/rubycode2.zip rename to vendor/plugins/rubyzip/test/data/rubycode2.zip diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/testDirectory.bin b/vendor/plugins/rubyzip/test/data/testDirectory.bin similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/testDirectory.bin rename to vendor/plugins/rubyzip/test/data/testDirectory.bin diff --git a/vendor/plugins/rubyzip-0.9.1/test/data/zipWithDirs.zip b/vendor/plugins/rubyzip/test/data/zipWithDirs.zip similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/data/zipWithDirs.zip rename to vendor/plugins/rubyzip/test/data/zipWithDirs.zip diff --git a/vendor/plugins/rubyzip-0.9.1/test/gentestfiles.rb b/vendor/plugins/rubyzip/test/gentestfiles.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/gentestfiles.rb rename to vendor/plugins/rubyzip/test/gentestfiles.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/ioextrastest.rb b/vendor/plugins/rubyzip/test/ioextrastest.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/ioextrastest.rb rename to vendor/plugins/rubyzip/test/ioextrastest.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/stdrubyexttest.rb b/vendor/plugins/rubyzip/test/stdrubyexttest.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/stdrubyexttest.rb rename to vendor/plugins/rubyzip/test/stdrubyexttest.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/zipfilesystemtest.rb b/vendor/plugins/rubyzip/test/zipfilesystemtest.rb similarity index 97% rename from vendor/plugins/rubyzip-0.9.1/test/zipfilesystemtest.rb rename to vendor/plugins/rubyzip/test/zipfilesystemtest.rb index f17b2d80..6969e03f 100755 --- a/vendor/plugins/rubyzip-0.9.1/test/zipfilesystemtest.rb +++ b/vendor/plugins/rubyzip/test/zipfilesystemtest.rb @@ -6,6 +6,7 @@ $: << "../lib" require 'zip/zipfilesystem' require 'test/unit' +require 'fileutils' module ExtraAssertions @@ -23,7 +24,7 @@ module ExtraAssertions assert_equal(retVal, yield) # Invoke test assert_equal(expectedArgs, callArgs) ensure - anObject.instance_eval "alias #{method} #{method}_org" + anObject.instance_eval "undef #{method}; alias #{method} #{method}_org" end end @@ -67,6 +68,15 @@ class ZipFsFileNonmutatingTest < Test::Unit::TestCase } assert(blockCalled) + blockCalled = false + @zipFile.file.open("file1", "rb") { # test binary flag is ignored + |f| + blockCalled = true + assert_equal("this is the entry 'file1' in my test archive!", + f.readline.chomp) + } + assert(blockCalled) + blockCalled = false @zipFile.dir.chdir "dir2" @zipFile.file.open("file21", "r") { @@ -552,7 +562,7 @@ end class ZipFsFileMutatingTest < Test::Unit::TestCase TEST_ZIP = "zipWithDirs_copy.zip" def setup - File.copy("data/zipWithDirs.zip", TEST_ZIP) + FileUtils.cp("data/zipWithDirs.zip", TEST_ZIP) end def teardown @@ -579,7 +589,7 @@ class ZipFsFileMutatingTest < Test::Unit::TestCase zf.file.read("test_open_write_entry")) # Test with existing entry - zf.file.open("file1", "w") { + zf.file.open("file1", "wb") { #also check that 'b' option is ignored |f| blockCalled = true f.write "This is what I'm writing too" @@ -640,7 +650,7 @@ class ZipFsDirectoryTest < Test::Unit::TestCase TEST_ZIP = "zipWithDirs_copy.zip" def setup - File.copy("data/zipWithDirs.zip", TEST_ZIP) + FileUtils.cp("data/zipWithDirs.zip", TEST_ZIP) end def test_delete diff --git a/vendor/plugins/rubyzip-0.9.1/test/ziprequiretest.rb b/vendor/plugins/rubyzip/test/ziprequiretest.rb similarity index 100% rename from vendor/plugins/rubyzip-0.9.1/test/ziprequiretest.rb rename to vendor/plugins/rubyzip/test/ziprequiretest.rb diff --git a/vendor/plugins/rubyzip-0.9.1/test/ziptest.rb b/vendor/plugins/rubyzip/test/ziptest.rb similarity index 98% rename from vendor/plugins/rubyzip-0.9.1/test/ziptest.rb rename to vendor/plugins/rubyzip/test/ziptest.rb index 56176446..70cdd44f 100755 --- a/vendor/plugins/rubyzip-0.9.1/test/ziptest.rb +++ b/vendor/plugins/rubyzip/test/ziptest.rb @@ -5,6 +5,7 @@ $VERBOSE = true $: << "../lib" require 'test/unit' +require 'fileutils' require 'zip/zip' require 'gentestfiles' @@ -1016,7 +1017,7 @@ module CommonZipFileFixture def setup File.delete(EMPTY_FILENAME) if File.exists?(EMPTY_FILENAME) - File.copy(TestZipFile::TEST_ZIP2.zip_name, TEST_ZIP.zip_name) + FileUtils.cp(TestZipFile::TEST_ZIP2.zip_name, TEST_ZIP.zip_name) end end @@ -1126,7 +1127,7 @@ class ZipFileTest < Test::Unit::TestCase def test_remove entryToRemove, *remainingEntries = TEST_ZIP.entry_names - File.copy(TestZipFile::TEST_ZIP2.zip_name, TEST_ZIP.zip_name) + FileUtils.cp(TestZipFile::TEST_ZIP2.zip_name, TEST_ZIP.zip_name) zf = ZipFile.new(TEST_ZIP.zip_name) assert(zf.entries.map { |e| e.name }.include?(entryToRemove)) @@ -1141,24 +1142,27 @@ class ZipFileTest < Test::Unit::TestCase zfRead.close end - def test_rename entryToRename, *remainingEntries = TEST_ZIP.entry_names - + zf = ZipFile.new(TEST_ZIP.zip_name) assert(zf.entries.map { |e| e.name }.include?(entryToRename)) - - newName = "changed name" + + contents = zf.read(entryToRename) + newName = "changed entry name" assert(! zf.entries.map { |e| e.name }.include?(newName)) zf.rename(entryToRename, newName) assert(zf.entries.map { |e| e.name }.include?(newName)) + assert_equal(contents, zf.read(newName)) + zf.close zfRead = ZipFile.new(TEST_ZIP.zip_name) assert(zfRead.entries.map { |e| e.name }.include?(newName)) - zfRead.close + assert_equal(contents, zf.read(newName)) + zfRead.close end def test_renameToExistingEntry @@ -1271,12 +1275,12 @@ class ZipFileTest < Test::Unit::TestCase # can delete the file you used to add the entry to the zip file # with def test_commitUseZipEntry - File.copy(TestFiles::RANDOM_ASCII_FILE1, "okToDelete.txt") + FileUtils.cp(TestFiles::RANDOM_ASCII_FILE1, "okToDelete.txt") zf = ZipFile.open(TEST_ZIP.zip_name) zf.add("okToDelete.txt", "okToDelete.txt") assert_contains(zf, "okToDelete.txt") zf.commit - File.move("okToDelete.txt", "okToDeleteMoved.txt") + File.rename("okToDelete.txt", "okToDeleteMoved.txt") assert_contains(zf, "okToDelete.txt", "okToDeleteMoved.txt") end