rubyzip 1.3.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -8
  3. data/Rakefile +3 -0
  4. data/lib/zip.rb +4 -3
  5. data/lib/zip/central_directory.rb +9 -5
  6. data/lib/zip/constants.rb +52 -0
  7. data/lib/zip/crypto/decrypted_io.rb +40 -0
  8. data/lib/zip/crypto/traditional_encryption.rb +9 -9
  9. data/lib/zip/decompressor.rb +19 -1
  10. data/lib/zip/dos_time.rb +12 -7
  11. data/lib/zip/entry.rb +57 -38
  12. data/lib/zip/entry_set.rb +2 -0
  13. data/lib/zip/errors.rb +1 -0
  14. data/lib/zip/extra_field.rb +11 -9
  15. data/lib/zip/extra_field/generic.rb +10 -9
  16. data/lib/zip/extra_field/ntfs.rb +4 -0
  17. data/lib/zip/extra_field/old_unix.rb +3 -1
  18. data/lib/zip/extra_field/universal_time.rb +42 -12
  19. data/lib/zip/extra_field/unix.rb +3 -1
  20. data/lib/zip/extra_field/zip64.rb +4 -2
  21. data/lib/zip/file.rb +79 -54
  22. data/lib/zip/filesystem.rb +193 -177
  23. data/lib/zip/inflater.rb +24 -36
  24. data/lib/zip/input_stream.rb +33 -26
  25. data/lib/zip/ioextras.rb +1 -1
  26. data/lib/zip/ioextras/abstract_input_stream.rb +19 -8
  27. data/lib/zip/ioextras/abstract_output_stream.rb +1 -1
  28. data/lib/zip/null_decompressor.rb +1 -9
  29. data/lib/zip/output_stream.rb +14 -5
  30. data/lib/zip/pass_thru_compressor.rb +2 -2
  31. data/lib/zip/pass_thru_decompressor.rb +13 -22
  32. data/lib/zip/streamable_directory.rb +3 -3
  33. data/lib/zip/streamable_stream.rb +6 -10
  34. data/lib/zip/version.rb +1 -1
  35. data/samples/example.rb +2 -2
  36. data/samples/example_filesystem.rb +1 -1
  37. data/samples/gtk_ruby_zip.rb +19 -19
  38. data/samples/qtzip.rb +6 -6
  39. data/samples/write_simple.rb +2 -4
  40. data/samples/zipfind.rb +23 -22
  41. metadata +28 -169
  42. data/test/basic_zip_file_test.rb +0 -60
  43. data/test/case_sensitivity_test.rb +0 -69
  44. data/test/central_directory_entry_test.rb +0 -69
  45. data/test/central_directory_test.rb +0 -100
  46. data/test/crypto/null_encryption_test.rb +0 -57
  47. data/test/crypto/traditional_encryption_test.rb +0 -80
  48. data/test/data/WarnInvalidDate.zip +0 -0
  49. data/test/data/file1.txt +0 -46
  50. data/test/data/file1.txt.deflatedData +0 -0
  51. data/test/data/file2.txt +0 -1504
  52. data/test/data/globTest.zip +0 -0
  53. data/test/data/globTest/foo.txt +0 -0
  54. data/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  55. data/test/data/globTest/food.txt +0 -0
  56. data/test/data/gpbit3stored.zip +0 -0
  57. data/test/data/mimetype +0 -1
  58. data/test/data/notzippedruby.rb +0 -7
  59. data/test/data/ntfs.zip +0 -0
  60. data/test/data/oddExtraField.zip +0 -0
  61. data/test/data/path_traversal/Makefile +0 -10
  62. data/test/data/path_traversal/jwilk/README.md +0 -5
  63. data/test/data/path_traversal/jwilk/absolute1.zip +0 -0
  64. data/test/data/path_traversal/jwilk/absolute2.zip +0 -0
  65. data/test/data/path_traversal/jwilk/dirsymlink.zip +0 -0
  66. data/test/data/path_traversal/jwilk/dirsymlink2a.zip +0 -0
  67. data/test/data/path_traversal/jwilk/dirsymlink2b.zip +0 -0
  68. data/test/data/path_traversal/jwilk/relative0.zip +0 -0
  69. data/test/data/path_traversal/jwilk/relative2.zip +0 -0
  70. data/test/data/path_traversal/jwilk/symlink.zip +0 -0
  71. data/test/data/path_traversal/relative1.zip +0 -0
  72. data/test/data/path_traversal/tilde.zip +0 -0
  73. data/test/data/path_traversal/tuzovakaoff/README.md +0 -3
  74. data/test/data/path_traversal/tuzovakaoff/absolutepath.zip +0 -0
  75. data/test/data/path_traversal/tuzovakaoff/symlink.zip +0 -0
  76. data/test/data/rubycode.zip +0 -0
  77. data/test/data/rubycode2.zip +0 -0
  78. data/test/data/test.xls +0 -0
  79. data/test/data/testDirectory.bin +0 -0
  80. data/test/data/zip64-sample.zip +0 -0
  81. data/test/data/zipWithDirs.zip +0 -0
  82. data/test/data/zipWithEncryption.zip +0 -0
  83. data/test/deflater_test.rb +0 -65
  84. data/test/encryption_test.rb +0 -42
  85. data/test/entry_set_test.rb +0 -163
  86. data/test/entry_test.rb +0 -154
  87. data/test/errors_test.rb +0 -35
  88. data/test/extra_field_test.rb +0 -76
  89. data/test/file_extract_directory_test.rb +0 -54
  90. data/test/file_extract_test.rb +0 -145
  91. data/test/file_permissions_test.rb +0 -65
  92. data/test/file_split_test.rb +0 -57
  93. data/test/file_test.rb +0 -666
  94. data/test/filesystem/dir_iterator_test.rb +0 -58
  95. data/test/filesystem/directory_test.rb +0 -139
  96. data/test/filesystem/file_mutating_test.rb +0 -87
  97. data/test/filesystem/file_nonmutating_test.rb +0 -508
  98. data/test/filesystem/file_stat_test.rb +0 -64
  99. data/test/gentestfiles.rb +0 -126
  100. data/test/inflater_test.rb +0 -14
  101. data/test/input_stream_test.rb +0 -182
  102. data/test/ioextras/abstract_input_stream_test.rb +0 -102
  103. data/test/ioextras/abstract_output_stream_test.rb +0 -106
  104. data/test/ioextras/fake_io_test.rb +0 -18
  105. data/test/local_entry_test.rb +0 -154
  106. data/test/output_stream_test.rb +0 -128
  107. data/test/pass_thru_compressor_test.rb +0 -30
  108. data/test/pass_thru_decompressor_test.rb +0 -14
  109. data/test/path_traversal_test.rb +0 -141
  110. data/test/samples/example_recursive_test.rb +0 -37
  111. data/test/settings_test.rb +0 -95
  112. data/test/test_helper.rb +0 -234
  113. data/test/unicode_file_names_and_comments_test.rb +0 -62
  114. data/test/zip64_full_test.rb +0 -51
  115. data/test/zip64_support_test.rb +0 -14
@@ -1,106 +0,0 @@
1
- require 'test_helper'
2
- require 'zip/ioextras'
3
-
4
- class AbstractOutputStreamTest < MiniTest::Test
5
- class TestOutputStream
6
- include ::Zip::IOExtras::AbstractOutputStream
7
-
8
- attr_accessor :buffer
9
-
10
- def initialize
11
- @buffer = ''
12
- end
13
-
14
- def <<(data)
15
- @buffer << data
16
- self
17
- end
18
- end
19
-
20
- def setup
21
- @output_stream = TestOutputStream.new
22
-
23
- @origCommaSep = $,
24
- @origOutputSep = $\
25
- end
26
-
27
- def teardown
28
- $, = @origCommaSep
29
- $\ = @origOutputSep
30
- end
31
-
32
- def test_write
33
- count = @output_stream.write('a little string')
34
- assert_equal('a little string', @output_stream.buffer)
35
- assert_equal('a little string'.length, count)
36
-
37
- count = @output_stream.write('. a little more')
38
- assert_equal('a little string. a little more', @output_stream.buffer)
39
- assert_equal('. a little more'.length, count)
40
- end
41
-
42
- def test_print
43
- $\ = nil # record separator set to nil
44
- @output_stream.print('hello')
45
- assert_equal('hello', @output_stream.buffer)
46
-
47
- @output_stream.print(' world.')
48
- assert_equal('hello world.', @output_stream.buffer)
49
-
50
- @output_stream.print(' You ok ', 'out ', 'there?')
51
- assert_equal('hello world. You ok out there?', @output_stream.buffer)
52
-
53
- $\ = "\n"
54
- @output_stream.print
55
- assert_equal("hello world. You ok out there?\n", @output_stream.buffer)
56
-
57
- @output_stream.print('I sure hope so!')
58
- assert_equal("hello world. You ok out there?\nI sure hope so!\n", @output_stream.buffer)
59
-
60
- $, = 'X'
61
- @output_stream.buffer = ''
62
- @output_stream.print('monkey', 'duck', 'zebra')
63
- assert_equal("monkeyXduckXzebra\n", @output_stream.buffer)
64
-
65
- $\ = nil
66
- @output_stream.buffer = ''
67
- @output_stream.print(20)
68
- assert_equal('20', @output_stream.buffer)
69
- end
70
-
71
- def test_printf
72
- @output_stream.printf('%d %04x', 123, 123)
73
- assert_equal('123 007b', @output_stream.buffer)
74
- end
75
-
76
- def test_putc
77
- @output_stream.putc('A')
78
- assert_equal('A', @output_stream.buffer)
79
- @output_stream.putc(65)
80
- assert_equal('AA', @output_stream.buffer)
81
- end
82
-
83
- def test_puts
84
- @output_stream.puts
85
- assert_equal("\n", @output_stream.buffer)
86
-
87
- @output_stream.puts('hello', 'world')
88
- assert_equal("\nhello\nworld\n", @output_stream.buffer)
89
-
90
- @output_stream.buffer = ''
91
- @output_stream.puts("hello\n", "world\n")
92
- assert_equal("hello\nworld\n", @output_stream.buffer)
93
-
94
- @output_stream.buffer = ''
95
- @output_stream.puts(%W[hello\n world\n])
96
- assert_equal("hello\nworld\n", @output_stream.buffer)
97
-
98
- @output_stream.buffer = ''
99
- @output_stream.puts(%W[hello\n world\n], 'bingo')
100
- assert_equal("hello\nworld\nbingo\n", @output_stream.buffer)
101
-
102
- @output_stream.buffer = ''
103
- @output_stream.puts(16, 20, 50, 'hello')
104
- assert_equal("16\n20\n50\nhello\n", @output_stream.buffer)
105
- end
106
- end
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
- require 'zip/ioextras'
3
-
4
- class FakeIOTest < MiniTest::Test
5
- class FakeIOUsingClass
6
- include ::Zip::IOExtras::FakeIO
7
- end
8
-
9
- def test_kind_of?
10
- obj = FakeIOUsingClass.new
11
-
12
- assert(obj.kind_of?(Object))
13
- assert(obj.kind_of?(FakeIOUsingClass))
14
- assert(obj.kind_of?(IO))
15
- assert(!obj.kind_of?(Integer))
16
- assert(!obj.kind_of?(String))
17
- end
18
- end
@@ -1,154 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipLocalEntryTest < MiniTest::Test
4
- CEH_FILE = 'test/data/generated/centralEntryHeader.bin'
5
- LEH_FILE = 'test/data/generated/localEntryHeader.bin'
6
-
7
- def teardown
8
- ::Zip.write_zip64_support = false
9
- end
10
-
11
- def test_read_local_entry_header_of_first_test_zip_entry
12
- ::File.open(TestZipFile::TEST_ZIP3.zip_name, 'rb') do |file|
13
- entry = ::Zip::Entry.read_local_entry(file)
14
-
15
- assert_equal('', entry.comment)
16
- # Differs from windows and unix because of CR LF
17
- # assert_equal(480, entry.compressed_size)
18
- # assert_equal(0x2a27930f, entry.crc)
19
- # extra field is 21 bytes long
20
- # probably contains some unix attrutes or something
21
- # disabled: assert_equal(nil, entry.extra)
22
- assert_equal(::Zip::Entry::DEFLATED, entry.compression_method)
23
- assert_equal(TestZipFile::TEST_ZIP3.entry_names[0], entry.name)
24
- assert_equal(::File.size(TestZipFile::TEST_ZIP3.entry_names[0]), entry.size)
25
- assert(!entry.directory?)
26
- end
27
- end
28
-
29
- def test_read_date_time
30
- ::File.open('test/data/rubycode.zip', 'rb') do |file|
31
- entry = ::Zip::Entry.read_local_entry(file)
32
- assert_equal('zippedruby1.rb', entry.name)
33
- assert_equal(::Zip::DOSTime.at(1_019_261_638), entry.time)
34
- end
35
- end
36
-
37
- def test_read_local_entry_from_non_zip_file
38
- ::File.open('test/data/file2.txt') do |file|
39
- assert_nil(::Zip::Entry.read_local_entry(file))
40
- end
41
- end
42
-
43
- def test_read_local_entry_from_truncated_zip_file
44
- zipFragment = ''
45
- ::File.open(TestZipFile::TEST_ZIP2.zip_name) { |f| zipFragment = f.read(12) } # local header is at least 30 bytes
46
- zipFragment.extend(IOizeString).reset
47
- entry = ::Zip::Entry.new
48
- entry.read_local_entry(zipFragment)
49
- fail 'ZipError expected'
50
- rescue ::Zip::Error
51
- end
52
-
53
- def test_write_entry
54
- entry = ::Zip::Entry.new('file.zip', 'entryName', 'my little comment',
55
- 'thisIsSomeExtraInformation', 100, 987_654,
56
- ::Zip::Entry::DEFLATED, 400)
57
- write_to_file(LEH_FILE, CEH_FILE, entry)
58
- entryReadLocal, entryReadCentral = read_from_file(LEH_FILE, CEH_FILE)
59
- assert(entryReadCentral.extra['Zip64Placeholder'].nil?, 'zip64 placeholder should not be used in central directory')
60
- compare_local_entry_headers(entry, entryReadLocal)
61
- compare_c_dir_entry_headers(entry, entryReadCentral)
62
- end
63
-
64
- def test_write_entry_with_zip64
65
- ::Zip.write_zip64_support = true
66
- entry = ::Zip::Entry.new('file.zip', 'entryName', 'my little comment',
67
- 'thisIsSomeExtraInformation', 100, 987_654,
68
- ::Zip::Entry::DEFLATED, 400)
69
- write_to_file(LEH_FILE, CEH_FILE, entry)
70
- entryReadLocal, entryReadCentral = read_from_file(LEH_FILE, CEH_FILE)
71
- assert(entryReadLocal.extra['Zip64Placeholder'], 'zip64 placeholder should be used in local file header')
72
- entryReadLocal.extra.delete('Zip64Placeholder') # it was removed when writing the c_dir_entry, so remove from compare
73
- assert(entryReadCentral.extra['Zip64Placeholder'].nil?, 'zip64 placeholder should not be used in central directory')
74
- compare_local_entry_headers(entry, entryReadLocal)
75
- compare_c_dir_entry_headers(entry, entryReadCentral)
76
- end
77
-
78
- def test_write_64entry
79
- ::Zip.write_zip64_support = true
80
- entry = ::Zip::Entry.new('bigfile.zip', 'entryName', 'my little equine',
81
- 'malformed extra field because why not',
82
- 0x7766554433221100, 0xDEADBEEF, ::Zip::Entry::DEFLATED,
83
- 0x9988776655443322)
84
- write_to_file(LEH_FILE, CEH_FILE, entry)
85
- entryReadLocal, entryReadCentral = read_from_file(LEH_FILE, CEH_FILE)
86
- compare_local_entry_headers(entry, entryReadLocal)
87
- compare_c_dir_entry_headers(entry, entryReadCentral)
88
- end
89
-
90
- def test_rewrite_local_header64
91
- ::Zip.write_zip64_support = true
92
- buf1 = StringIO.new
93
- entry = ::Zip::Entry.new('file.zip', 'entryName')
94
- entry.write_local_entry(buf1)
95
- assert(entry.extra['Zip64'].nil?, 'zip64 extra is unnecessarily present')
96
-
97
- buf2 = StringIO.new
98
- entry.size = 0x123456789ABCDEF0
99
- entry.compressed_size = 0x0123456789ABCDEF
100
- entry.write_local_entry(buf2, true)
101
- refute_nil(entry.extra['Zip64'])
102
- refute_equal(buf1.size, 0)
103
- assert_equal(buf1.size, buf2.size) # it can't grow, or we'd clobber file data
104
- end
105
-
106
- def test_read_local_offset
107
- entry = ::Zip::Entry.new('file.zip', 'entryName')
108
- entry.local_header_offset = 12_345
109
- ::File.open(CEH_FILE, 'wb') { |f| entry.write_c_dir_entry(f) }
110
- read_entry = nil
111
- ::File.open(CEH_FILE, 'rb') { |f| read_entry = ::Zip::Entry.read_c_dir_entry(f) }
112
- compare_c_dir_entry_headers(entry, read_entry)
113
- end
114
-
115
- def test_read64_local_offset
116
- ::Zip.write_zip64_support = true
117
- entry = ::Zip::Entry.new('file.zip', 'entryName')
118
- entry.local_header_offset = 0x0123456789ABCDEF
119
- ::File.open(CEH_FILE, 'wb') { |f| entry.write_c_dir_entry(f) }
120
- read_entry = nil
121
- ::File.open(CEH_FILE, 'rb') { |f| read_entry = ::Zip::Entry.read_c_dir_entry(f) }
122
- compare_c_dir_entry_headers(entry, read_entry)
123
- end
124
-
125
- private
126
-
127
- def compare_local_entry_headers(entry1, entry2)
128
- assert_equal(entry1.compressed_size, entry2.compressed_size)
129
- assert_equal(entry1.crc, entry2.crc)
130
- assert_equal(entry1.extra, entry2.extra)
131
- assert_equal(entry1.compression_method, entry2.compression_method)
132
- assert_equal(entry1.name, entry2.name)
133
- assert_equal(entry1.size, entry2.size)
134
- assert_equal(entry1.local_header_offset, entry2.local_header_offset)
135
- end
136
-
137
- def compare_c_dir_entry_headers(entry1, entry2)
138
- compare_local_entry_headers(entry1, entry2)
139
- assert_equal(entry1.comment, entry2.comment)
140
- end
141
-
142
- def write_to_file(localFileName, centralFileName, entry)
143
- ::File.open(localFileName, 'wb') { |f| entry.write_local_entry(f) }
144
- ::File.open(centralFileName, 'wb') { |f| entry.write_c_dir_entry(f) }
145
- end
146
-
147
- def read_from_file(localFileName, centralFileName)
148
- localEntry = nil
149
- cdirEntry = nil
150
- ::File.open(localFileName, 'rb') { |f| localEntry = ::Zip::Entry.read_local_entry(f) }
151
- ::File.open(centralFileName, 'rb') { |f| cdirEntry = ::Zip::Entry.read_c_dir_entry(f) }
152
- [localEntry, cdirEntry]
153
- end
154
- end
@@ -1,128 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ZipOutputStreamTest < MiniTest::Test
4
- include AssertEntry
5
-
6
- TEST_ZIP = TestZipFile::TEST_ZIP2.clone
7
- TEST_ZIP.zip_name = 'test/data/generated/output.zip'
8
-
9
- def test_new
10
- zos = ::Zip::OutputStream.new(TEST_ZIP.zip_name)
11
- zos.comment = TEST_ZIP.comment
12
- write_test_zip(zos)
13
- zos.close
14
- assert_test_zip_contents(TEST_ZIP)
15
- end
16
-
17
- def test_open
18
- ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
19
- zos.comment = TEST_ZIP.comment
20
- write_test_zip(zos)
21
- end
22
- assert_test_zip_contents(TEST_ZIP)
23
- end
24
-
25
- def test_write_buffer
26
- io = ::StringIO.new('')
27
- buffer = ::Zip::OutputStream.write_buffer(io) do |zos|
28
- zos.comment = TEST_ZIP.comment
29
- write_test_zip(zos)
30
- end
31
- File.open(TEST_ZIP.zip_name, 'wb') { |f| f.write buffer.string }
32
- assert_test_zip_contents(TEST_ZIP)
33
- end
34
-
35
- def test_write_buffer_with_temp_file
36
- tmp_file = Tempfile.new('')
37
-
38
- ::Zip::OutputStream.write_buffer(tmp_file) do |zos|
39
- zos.comment = TEST_ZIP.comment
40
- write_test_zip(zos)
41
- end
42
-
43
- tmp_file.rewind
44
- File.open(TEST_ZIP.zip_name, 'wb') { |f| f.write(tmp_file.read) }
45
- tmp_file.unlink
46
-
47
- assert_test_zip_contents(TEST_ZIP)
48
- end
49
-
50
- def test_writing_to_closed_stream
51
- assert_i_o_error_in_closed_stream { |zos| zos << 'hello world' }
52
- assert_i_o_error_in_closed_stream { |zos| zos.puts 'hello world' }
53
- assert_i_o_error_in_closed_stream { |zos| zos.write 'hello world' }
54
- end
55
-
56
- def test_cannot_open_file
57
- name = TestFiles::EMPTY_TEST_DIR
58
- begin
59
- ::Zip::OutputStream.open(name)
60
- rescue Exception
61
- assert($!.kind_of?(Errno::EISDIR) || # Linux
62
- $!.kind_of?(Errno::EEXIST) || # Windows/cygwin
63
- $!.kind_of?(Errno::EACCES), # Windows
64
- "Expected Errno::EISDIR (or on win/cygwin: Errno::EEXIST), but was: #{$!.class}")
65
- end
66
- end
67
-
68
- def test_put_next_entry
69
- stored_text = 'hello world in stored text'
70
- entry_name = 'file1'
71
- comment = 'my comment'
72
- ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
73
- zos.put_next_entry(entry_name, comment, nil, ::Zip::Entry::STORED)
74
- zos << stored_text
75
- end
76
-
77
- assert(File.read(TEST_ZIP.zip_name)[stored_text])
78
- ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
79
- assert_equal(stored_text, zf.read(entry_name))
80
- end
81
- end
82
-
83
- def test_put_next_entry_using_zip_entry_creates_entries_with_correct_timestamps
84
- file = ::File.open('test/data/file2.txt', 'rb')
85
- ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
86
- zip_entry = ::Zip::Entry.new(zos, file.path, '', '', 0, 0, ::Zip::Entry::DEFLATED, 0, ::Zip::DOSTime.at(file.mtime))
87
- zos.put_next_entry(zip_entry)
88
- zos << file.read
89
- end
90
-
91
- ::Zip::InputStream.open(TEST_ZIP.zip_name) do |io|
92
- while (entry = io.get_next_entry)
93
- assert(::Zip::DOSTime.at(file.mtime).dos_equals(::Zip::DOSTime.at(entry.mtime))) # Compare DOS Times, since they are stored with two seconds accuracy
94
- end
95
- end
96
- end
97
-
98
- def test_chained_put_into_next_entry
99
- stored_text = 'hello world in stored text'
100
- stored_text2 = 'with chain'
101
- entry_name = 'file1'
102
- comment = 'my comment'
103
- ::Zip::OutputStream.open(TEST_ZIP.zip_name) do |zos|
104
- zos.put_next_entry(entry_name, comment, nil, ::Zip::Entry::STORED)
105
- zos << stored_text << stored_text2
106
- end
107
-
108
- assert(File.read(TEST_ZIP.zip_name)[stored_text])
109
- ::Zip::File.open(TEST_ZIP.zip_name) do |zf|
110
- assert_equal(stored_text + stored_text2, zf.read(entry_name))
111
- end
112
- end
113
-
114
- def assert_i_o_error_in_closed_stream
115
- assert_raises(IOError) do
116
- zos = ::Zip::OutputStream.new('test/data/generated/test_putOnClosedStream.zip')
117
- zos.close
118
- yield zos
119
- end
120
- end
121
-
122
- def write_test_zip(zos)
123
- TEST_ZIP.entry_names.each do |entryName|
124
- zos.put_next_entry(entryName)
125
- File.open(entryName, 'rb') { |f| zos.write(f.read) }
126
- end
127
- end
128
- end
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PassThruCompressorTest < MiniTest::Test
4
- include CrcTest
5
-
6
- def test_size
7
- File.open('test/data/generated/dummy.txt', 'wb') do |file|
8
- compressor = ::Zip::PassThruCompressor.new(file)
9
-
10
- assert_equal(0, compressor.size)
11
-
12
- t1 = 'hello world'
13
- t2 = ''
14
- t3 = 'bingo'
15
-
16
- compressor << t1
17
- assert_equal(compressor.size, t1.size)
18
-
19
- compressor << t2
20
- assert_equal(compressor.size, t1.size + t2.size)
21
-
22
- compressor << t3
23
- assert_equal(compressor.size, t1.size + t2.size + t3.size)
24
- end
25
- end
26
-
27
- def test_crc
28
- run_crc_test(::Zip::PassThruCompressor)
29
- end
30
- end
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
- class PassThruDecompressorTest < MiniTest::Test
3
- include DecompressorTests
4
-
5
- def setup
6
- super
7
- @file = File.new(TEST_FILE)
8
- @decompressor = ::Zip::PassThruDecompressor.new(@file, File.size(TEST_FILE))
9
- end
10
-
11
- def teardown
12
- @file.close
13
- end
14
- end