hotplate 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/hotplate.gemspec +1 -0
  3. data/lib/hotplate/cli/main.rb +1 -7
  4. data/lib/hotplate/version.rb +1 -1
  5. metadata +16 -101
  6. data/lib/hotplate/gems/rubyzip-1.1.7/README.md +0 -271
  7. data/lib/hotplate/gems/rubyzip-1.1.7/Rakefile +0 -19
  8. data/lib/hotplate/gems/rubyzip-1.1.7/TODO +0 -15
  9. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/central_directory.rb +0 -208
  10. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/compressor.rb +0 -10
  11. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/constants.rb +0 -63
  12. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/encryption.rb +0 -11
  13. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/null_encryption.rb +0 -45
  14. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/crypto/traditional_encryption.rb +0 -99
  15. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/decompressor.rb +0 -13
  16. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/deflater.rb +0 -32
  17. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/dos_time.rb +0 -49
  18. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry.rb +0 -696
  19. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/entry_set.rb +0 -86
  20. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/errors.rb +0 -16
  21. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/generic.rb +0 -43
  22. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/ntfs.rb +0 -92
  23. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/old_unix.rb +0 -45
  24. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/universal_time.rb +0 -47
  25. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/unix.rb +0 -38
  26. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64.rb +0 -67
  27. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field/zip64_placeholder.rb +0 -16
  28. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/extra_field.rb +0 -101
  29. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/file.rb +0 -436
  30. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/filesystem.rb +0 -626
  31. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/inflater.rb +0 -66
  32. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/input_stream.rb +0 -164
  33. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_input_stream.rb +0 -115
  34. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras/abstract_output_stream.rb +0 -45
  35. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/ioextras.rb +0 -38
  36. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_compressor.rb +0 -15
  37. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_decompressor.rb +0 -27
  38. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/null_input_stream.rb +0 -10
  39. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/output_stream.rb +0 -190
  40. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_compressor.rb +0 -23
  41. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/pass_thru_decompressor.rb +0 -41
  42. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_directory.rb +0 -15
  43. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/streamable_stream.rb +0 -56
  44. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip/version.rb +0 -3
  45. data/lib/hotplate/gems/rubyzip-1.1.7/lib/zip.rb +0 -63
  46. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example.rb +0 -91
  47. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_filesystem.rb +0 -33
  48. data/lib/hotplate/gems/rubyzip-1.1.7/samples/example_recursive.rb +0 -48
  49. data/lib/hotplate/gems/rubyzip-1.1.7/samples/gtkRubyzip.rb +0 -86
  50. data/lib/hotplate/gems/rubyzip-1.1.7/samples/qtzip.rb +0 -101
  51. data/lib/hotplate/gems/rubyzip-1.1.7/samples/write_simple.rb +0 -13
  52. data/lib/hotplate/gems/rubyzip-1.1.7/samples/zipfind.rb +0 -74
  53. data/lib/hotplate/gems/rubyzip-1.1.7/test/basic_zip_file_test.rb +0 -64
  54. data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_entry_test.rb +0 -73
  55. data/lib/hotplate/gems/rubyzip-1.1.7/test/central_directory_test.rb +0 -104
  56. data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/null_encryption_test.rb +0 -53
  57. data/lib/hotplate/gems/rubyzip-1.1.7/test/crypto/traditional_encryption_test.rb +0 -80
  58. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/WarnInvalidDate.zip +0 -0
  59. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt +0 -46
  60. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file1.txt.deflatedData +0 -0
  61. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/file2.txt +0 -1504
  62. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo/bar/baz/foo.txt +0 -0
  63. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/foo.txt +0 -0
  64. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest/food.txt +0 -0
  65. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/globTest.zip +0 -0
  66. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/mimetype +0 -1
  67. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/notzippedruby.rb +0 -7
  68. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/ntfs.zip +0 -0
  69. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode.zip +0 -0
  70. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/rubycode2.zip +0 -0
  71. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/testDirectory.bin +0 -0
  72. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zip64-sample.zip +0 -0
  73. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithDirs.zip +0 -0
  74. data/lib/hotplate/gems/rubyzip-1.1.7/test/data/zipWithEncryption.zip +0 -0
  75. data/lib/hotplate/gems/rubyzip-1.1.7/test/deflater_test.rb +0 -67
  76. data/lib/hotplate/gems/rubyzip-1.1.7/test/encryption_test.rb +0 -42
  77. data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_set_test.rb +0 -138
  78. data/lib/hotplate/gems/rubyzip-1.1.7/test/entry_test.rb +0 -165
  79. data/lib/hotplate/gems/rubyzip-1.1.7/test/errors_test.rb +0 -36
  80. data/lib/hotplate/gems/rubyzip-1.1.7/test/extra_field_test.rb +0 -78
  81. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_directory_test.rb +0 -56
  82. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_extract_test.rb +0 -90
  83. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_split_test.rb +0 -60
  84. data/lib/hotplate/gems/rubyzip-1.1.7/test/file_test.rb +0 -559
  85. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/dir_iterator_test.rb +0 -62
  86. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/directory_test.rb +0 -131
  87. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_mutating_test.rb +0 -100
  88. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_nonmutating_test.rb +0 -514
  89. data/lib/hotplate/gems/rubyzip-1.1.7/test/filesystem/file_stat_test.rb +0 -66
  90. data/lib/hotplate/gems/rubyzip-1.1.7/test/gentestfiles.rb +0 -134
  91. data/lib/hotplate/gems/rubyzip-1.1.7/test/inflater_test.rb +0 -14
  92. data/lib/hotplate/gems/rubyzip-1.1.7/test/input_stream_test.rb +0 -170
  93. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_input_stream_test.rb +0 -103
  94. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/abstract_output_stream_test.rb +0 -106
  95. data/lib/hotplate/gems/rubyzip-1.1.7/test/ioextras/fake_io_test.rb +0 -18
  96. data/lib/hotplate/gems/rubyzip-1.1.7/test/local_entry_test.rb +0 -156
  97. data/lib/hotplate/gems/rubyzip-1.1.7/test/output_stream_test.rb +0 -129
  98. data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_compressor_test.rb +0 -31
  99. data/lib/hotplate/gems/rubyzip-1.1.7/test/pass_thru_decompressor_test.rb +0 -15
  100. data/lib/hotplate/gems/rubyzip-1.1.7/test/settings_test.rb +0 -92
  101. data/lib/hotplate/gems/rubyzip-1.1.7/test/test_helper.rb +0 -228
  102. data/lib/hotplate/gems/rubyzip-1.1.7/test/unicode_file_names_and_comments_test.rb +0 -52
  103. data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_full_test.rb +0 -53
  104. data/lib/hotplate/gems/rubyzip-1.1.7/test/zip64_support_test.rb +0 -15
@@ -1,208 +0,0 @@
1
- module Zip
2
- class CentralDirectory
3
- include Enumerable
4
-
5
- END_OF_CDS = 0x06054b50
6
- ZIP64_END_OF_CDS = 0x06064b50
7
- ZIP64_EOCD_LOCATOR = 0x07064b50
8
- MAX_END_OF_CDS_SIZE = 65536 + 18
9
- STATIC_EOCD_SIZE = 22
10
-
11
- attr_reader :comment
12
-
13
- # Returns an Enumerable containing the entries.
14
- def entries
15
- @entry_set.entries
16
- end
17
-
18
- def initialize(entries = EntrySet.new, comment = '') #:nodoc:
19
- super()
20
- @entry_set = entries.kind_of?(EntrySet) ? entries : EntrySet.new(entries)
21
- @comment = comment
22
- end
23
-
24
- def write_to_stream(io) #:nodoc:
25
- cdir_offset = io.tell
26
- @entry_set.each { |entry| entry.write_c_dir_entry(io) }
27
- eocd_offset = io.tell
28
- cdir_size = eocd_offset - cdir_offset
29
- if ::Zip.write_zip64_support
30
- need_zip64_eocd = cdir_offset > 0xFFFFFFFF || cdir_size > 0xFFFFFFFF || @entry_set.size > 0xFFFF
31
- need_zip64_eocd ||= @entry_set.any? { |entry| entry.extra['Zip64'] }
32
- if need_zip64_eocd
33
- write_64_e_o_c_d(io, cdir_offset, cdir_size)
34
- write_64_eocd_locator(io, eocd_offset)
35
- end
36
- end
37
- write_e_o_c_d(io, cdir_offset, cdir_size)
38
- end
39
-
40
- def write_e_o_c_d(io, offset, cdir_size) #:nodoc:
41
- tmp = [
42
- END_OF_CDS,
43
- 0, # @numberOfThisDisk
44
- 0, # @numberOfDiskWithStartOfCDir
45
- @entry_set ? [@entry_set.size, 0xFFFF].min : 0,
46
- @entry_set ? [@entry_set.size, 0xFFFF].min : 0,
47
- [cdir_size, 0xFFFFFFFF].min,
48
- [offset, 0xFFFFFFFF].min,
49
- @comment ? @comment.bytesize : 0
50
- ]
51
- io << tmp.pack('VvvvvVVv')
52
- io << @comment
53
- end
54
-
55
- private :write_e_o_c_d
56
-
57
- def write_64_e_o_c_d(io, offset, cdir_size) #:nodoc:
58
- tmp = [
59
- ZIP64_END_OF_CDS,
60
- 44, # size of zip64 end of central directory record (excludes signature and field itself)
61
- VERSION_MADE_BY,
62
- VERSION_NEEDED_TO_EXTRACT_ZIP64,
63
- 0, # @numberOfThisDisk
64
- 0, # @numberOfDiskWithStartOfCDir
65
- @entry_set ? @entry_set.size : 0, # number of entries on this disk
66
- @entry_set ? @entry_set.size : 0, # number of entries total
67
- cdir_size, # size of central directory
68
- offset, # offset of start of central directory in its disk
69
- ]
70
- io << tmp.pack('VQ<vvVVQ<Q<Q<Q<')
71
- end
72
-
73
- private :write_64_e_o_c_d
74
-
75
- def write_64_eocd_locator(io, zip64_eocd_offset)
76
- tmp = [
77
- ZIP64_EOCD_LOCATOR,
78
- 0, # number of disk containing the start of zip64 eocd record
79
- zip64_eocd_offset, # offset of the start of zip64 eocd record in its disk
80
- 1 # total number of disks
81
- ]
82
- io << tmp.pack('VVQ<V')
83
- end
84
-
85
- private :write_64_eocd_locator
86
-
87
- def read_64_e_o_c_d(buf) #:nodoc:
88
- buf = get_64_e_o_c_d(buf)
89
- @size_of_zip64_e_o_c_d = Entry.read_zip_64_long(buf)
90
- @version_made_by = Entry.read_zip_short(buf)
91
- @version_needed_for_extract = Entry.read_zip_short(buf)
92
- @number_of_this_disk = Entry.read_zip_long(buf)
93
- @number_of_disk_with_start_of_cdir = Entry.read_zip_long(buf)
94
- @total_number_of_entries_in_cdir_on_this_disk = Entry.read_zip_64_long(buf)
95
- @size = Entry.read_zip_64_long(buf)
96
- @size_in_bytes = Entry.read_zip_64_long(buf)
97
- @cdir_offset = Entry.read_zip_64_long(buf)
98
- @zip_64_extensible = buf.slice!(0, buf.bytesize)
99
- raise Error, "Zip consistency problem while reading eocd structure" unless buf.size == 0
100
- end
101
-
102
- def read_e_o_c_d(buf) #:nodoc:
103
- buf = get_e_o_c_d(buf)
104
- @number_of_this_disk = Entry.read_zip_short(buf)
105
- @number_of_disk_with_start_of_cdir = Entry.read_zip_short(buf)
106
- @total_number_of_entries_in_cdir_on_this_disk = Entry.read_zip_short(buf)
107
- @size = Entry.read_zip_short(buf)
108
- @size_in_bytes = Entry.read_zip_long(buf)
109
- @cdir_offset = Entry.read_zip_long(buf)
110
- comment_length = Entry.read_zip_short(buf)
111
- @comment = if comment_length.to_i <= 0
112
- buf.slice!(0, buf.size)
113
- else
114
- buf.read(comment_length)
115
- end
116
- raise Error, "Zip consistency problem while reading eocd structure" unless buf.size == 0
117
- end
118
-
119
- def read_central_directory_entries(io) #:nodoc:
120
- begin
121
- io.seek(@cdir_offset, IO::SEEK_SET)
122
- rescue Errno::EINVAL
123
- raise Error, "Zip consistency problem while reading central directory entry"
124
- end
125
- @entry_set = EntrySet.new
126
- @size.times do
127
- @entry_set << Entry.read_c_dir_entry(io)
128
- end
129
- end
130
-
131
- def read_from_stream(io) #:nodoc:
132
- buf = start_buf(io)
133
- if self.zip64_file?(buf)
134
- read_64_e_o_c_d(buf)
135
- else
136
- read_e_o_c_d(buf)
137
- end
138
- read_central_directory_entries(io)
139
- end
140
-
141
- def get_e_o_c_d(buf) #:nodoc:
142
- sig_index = buf.rindex([END_OF_CDS].pack('V'))
143
- raise Error, "Zip end of central directory signature not found" unless sig_index
144
- buf = buf.slice!((sig_index + 4)..(buf.bytesize))
145
-
146
- def buf.read(count)
147
- slice!(0, count)
148
- end
149
-
150
- buf
151
- end
152
-
153
- def zip64_file?(buf)
154
- buf.rindex([ZIP64_END_OF_CDS].pack('V')) && buf.rindex([ZIP64_EOCD_LOCATOR].pack('V'))
155
- end
156
-
157
- def start_buf(io)
158
- begin
159
- io.seek(-MAX_END_OF_CDS_SIZE, IO::SEEK_END)
160
- rescue Errno::EINVAL
161
- io.seek(0, IO::SEEK_SET)
162
- end
163
- io.read
164
- end
165
-
166
- def get_64_e_o_c_d(buf) #:nodoc:
167
- zip_64_start = buf.rindex([ZIP64_END_OF_CDS].pack('V'))
168
- raise Error, "Zip64 end of central directory signature not found" unless zip_64_start
169
- zip_64_locator = buf.rindex([ZIP64_EOCD_LOCATOR].pack('V'))
170
- raise Error, "Zip64 end of central directory signature locator not found" unless zip_64_locator
171
- buf = buf.slice!((zip_64_start + 4)..zip_64_locator)
172
-
173
- def buf.read(count)
174
- slice!(0, count)
175
- end
176
-
177
- buf
178
- end
179
-
180
- # For iterating over the entries.
181
- def each(&proc)
182
- @entry_set.each(&proc)
183
- end
184
-
185
- # Returns the number of entries in the central directory (and
186
- # consequently in the zip archive).
187
- def size
188
- @entry_set.size
189
- end
190
-
191
- def self.read_from_stream(io) #:nodoc:
192
- cdir = new
193
- cdir.read_from_stream(io)
194
- return cdir
195
- rescue Error
196
- return nil
197
- end
198
-
199
- def ==(other) #:nodoc:
200
- return false unless other.kind_of?(CentralDirectory)
201
- @entry_set.entries.sort == other.entries.sort && comment == other.comment
202
- end
203
- end
204
- end
205
-
206
- # Copyright (C) 2002, 2003 Thomas Sondergaard
207
- # rubyzip is free software; you can redistribute it and/or
208
- # modify it under the terms of the ruby license.
@@ -1,10 +0,0 @@
1
- module Zip
2
- class Compressor #:nodoc:all
3
- def finish
4
- end
5
- end
6
- end
7
-
8
- # Copyright (C) 2002, 2003 Thomas Sondergaard
9
- # rubyzip is free software; you can redistribute it and/or
10
- # modify it under the terms of the ruby license.
@@ -1,63 +0,0 @@
1
- module Zip
2
- RUNNING_ON_WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/i
3
-
4
- CENTRAL_DIRECTORY_ENTRY_SIGNATURE = 0x02014b50
5
- CDIR_ENTRY_STATIC_HEADER_LENGTH = 46
6
-
7
- LOCAL_ENTRY_SIGNATURE = 0x04034b50
8
- LOCAL_ENTRY_STATIC_HEADER_LENGTH = 30
9
- LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH = 4+4+4
10
- VERSION_MADE_BY = 52 # this library's version
11
- VERSION_NEEDED_TO_EXTRACT = 20
12
- VERSION_NEEDED_TO_EXTRACT_ZIP64 = 45
13
-
14
- FILE_TYPE_FILE = 010
15
- FILE_TYPE_DIR = 004
16
- FILE_TYPE_SYMLINK = 012
17
-
18
- FSTYPE_FAT = 0
19
- FSTYPE_AMIGA = 1
20
- FSTYPE_VMS = 2
21
- FSTYPE_UNIX = 3
22
- FSTYPE_VM_CMS = 4
23
- FSTYPE_ATARI = 5
24
- FSTYPE_HPFS = 6
25
- FSTYPE_MAC = 7
26
- FSTYPE_Z_SYSTEM = 8
27
- FSTYPE_CPM = 9
28
- FSTYPE_TOPS20 = 10
29
- FSTYPE_NTFS = 11
30
- FSTYPE_QDOS = 12
31
- FSTYPE_ACORN = 13
32
- FSTYPE_VFAT = 14
33
- FSTYPE_MVS = 15
34
- FSTYPE_BEOS = 16
35
- FSTYPE_TANDEM = 17
36
- FSTYPE_THEOS = 18
37
- FSTYPE_MAC_OSX = 19
38
- FSTYPE_ATHEOS = 30
39
-
40
- FSTYPES = {
41
- FSTYPE_FAT => 'FAT'.freeze,
42
- FSTYPE_AMIGA => 'Amiga'.freeze,
43
- FSTYPE_VMS => 'VMS (Vax or Alpha AXP)'.freeze,
44
- FSTYPE_UNIX => 'Unix'.freeze,
45
- FSTYPE_VM_CMS => 'VM/CMS'.freeze,
46
- FSTYPE_ATARI => 'Atari ST'.freeze,
47
- FSTYPE_HPFS => 'OS/2 or NT HPFS'.freeze,
48
- FSTYPE_MAC => 'Macintosh'.freeze,
49
- FSTYPE_Z_SYSTEM => 'Z-System'.freeze,
50
- FSTYPE_CPM => 'CP/M'.freeze,
51
- FSTYPE_TOPS20 => 'TOPS-20'.freeze,
52
- FSTYPE_NTFS => 'NTFS'.freeze,
53
- FSTYPE_QDOS => 'SMS/QDOS'.freeze,
54
- FSTYPE_ACORN => 'Acorn RISC OS'.freeze,
55
- FSTYPE_VFAT => 'Win32 VFAT'.freeze,
56
- FSTYPE_MVS => 'MVS'.freeze,
57
- FSTYPE_BEOS => 'BeOS'.freeze,
58
- FSTYPE_TANDEM => 'Tandem NSK'.freeze,
59
- FSTYPE_THEOS => 'Theos'.freeze,
60
- FSTYPE_MAC_OSX => 'Mac OS/X (Darwin)'.freeze,
61
- FSTYPE_ATHEOS => 'AtheOS'.freeze,
62
- }.freeze
63
- end
@@ -1,11 +0,0 @@
1
- module Zip
2
- class Encrypter #:nodoc:all
3
- end
4
-
5
- class Decrypter
6
- end
7
- end
8
-
9
- # Copyright (C) 2002, 2003 Thomas Sondergaard
10
- # rubyzip is free software; you can redistribute it and/or
11
- # modify it under the terms of the ruby license.
@@ -1,45 +0,0 @@
1
- module Zip
2
- module NullEncryption
3
- def header_bytesize
4
- 0
5
- end
6
-
7
- def gp_flags
8
- 0
9
- end
10
- end
11
-
12
- class NullEncrypter < Encrypter
13
- include NullEncryption
14
-
15
- def header(mtime)
16
- ''
17
- end
18
-
19
- def encrypt(data)
20
- data
21
- end
22
-
23
- def data_descriptor(crc32, compressed_size, uncomprssed_size)
24
- ''
25
- end
26
-
27
- def reset!
28
- end
29
- end
30
-
31
- class NullDecrypter < Decrypter
32
- include NullEncryption
33
-
34
- def decrypt(data)
35
- data
36
- end
37
-
38
- def reset!(header)
39
- end
40
- end
41
- end
42
-
43
- # Copyright (C) 2002, 2003 Thomas Sondergaard
44
- # rubyzip is free software; you can redistribute it and/or
45
- # modify it under the terms of the ruby license.
@@ -1,99 +0,0 @@
1
- module Zip
2
- module TraditionalEncryption
3
- def initialize(password)
4
- @password = password
5
- reset_keys!
6
- end
7
-
8
- def header_bytesize
9
- 12
10
- end
11
-
12
- def gp_flags
13
- 0x0001 | 0x0008
14
- end
15
-
16
- protected
17
-
18
- def reset_keys!
19
- @key0 = 0x12345678
20
- @key1 = 0x23456789
21
- @key2 = 0x34567890
22
- @password.each_byte do |byte|
23
- update_keys(byte.chr)
24
- end
25
- end
26
-
27
- def update_keys(n)
28
- @key0 = ~Zlib.crc32(n, ~@key0)
29
- @key1 = ((@key1 + (@key0 & 0xff)) * 134775813 + 1) & 0xffffffff
30
- @key2 = ~Zlib.crc32((@key1 >> 24).chr, ~@key2)
31
- end
32
-
33
- def decrypt_byte
34
- temp = (@key2 & 0xffff) | 2
35
- ((temp * (temp ^ 1)) >> 8) & 0xff
36
- end
37
- end
38
-
39
- class TraditionalEncrypter < Encrypter
40
- include TraditionalEncryption
41
-
42
- def header(mtime)
43
- [].tap do |header|
44
- (header_bytesize - 2).times do
45
- header << Random.rand(0..255)
46
- end
47
- header << (mtime.to_binary_dos_time & 0xff)
48
- header << (mtime.to_binary_dos_time >> 8)
49
- end.map{|x| encode x}.pack("C*")
50
- end
51
-
52
- def encrypt(data)
53
- data.unpack("C*").map{|x| encode x}.pack("C*")
54
- end
55
-
56
- def data_descriptor(crc32, compressed_size, uncomprssed_size)
57
- [0x08074b50, crc32, compressed_size, uncomprssed_size].pack("VVVV")
58
- end
59
-
60
- def reset!
61
- reset_keys!
62
- end
63
-
64
- private
65
-
66
- def encode(n)
67
- t = decrypt_byte
68
- update_keys(n.chr)
69
- t ^ n
70
- end
71
- end
72
-
73
- class TraditionalDecrypter < Decrypter
74
- include TraditionalEncryption
75
-
76
- def decrypt(data)
77
- data.unpack("C*").map{|x| decode x}.pack("C*")
78
- end
79
-
80
- def reset!(header)
81
- reset_keys!
82
- header.each_byte do |x|
83
- decode x
84
- end
85
- end
86
-
87
- private
88
-
89
- def decode(n)
90
- n ^= decrypt_byte
91
- update_keys(n.chr)
92
- n
93
- end
94
- end
95
- end
96
-
97
- # Copyright (C) 2002, 2003 Thomas Sondergaard
98
- # rubyzip is free software; you can redistribute it and/or
99
- # modify it under the terms of the ruby license.
@@ -1,13 +0,0 @@
1
- module Zip
2
- class Decompressor #:nodoc:all
3
- CHUNK_SIZE = 32768
4
- def initialize(input_stream)
5
- super()
6
- @input_stream=input_stream
7
- end
8
- end
9
- end
10
-
11
- # Copyright (C) 2002, 2003 Thomas Sondergaard
12
- # rubyzip is free software; you can redistribute it and/or
13
- # modify it under the terms of the ruby license.
@@ -1,32 +0,0 @@
1
- module Zip
2
- class Deflater < Compressor #:nodoc:all
3
-
4
- def initialize(output_stream, level = Zip.default_compression, encrypter = NullEncrypter.new)
5
- super()
6
- @output_stream = output_stream
7
- @zlib_deflater = ::Zlib::Deflate.new(level, -::Zlib::MAX_WBITS)
8
- @size = 0
9
- @crc = ::Zlib.crc32
10
- @encrypter = encrypter
11
- @buffer_stream = ::StringIO.new('')
12
- end
13
-
14
- def << (data)
15
- val = data.to_s
16
- @crc = Zlib::crc32(val, @crc)
17
- @size += val.bytesize
18
- @buffer_stream << @zlib_deflater.deflate(data)
19
- end
20
-
21
- def finish
22
- @output_stream << @encrypter.encrypt(@buffer_stream.string)
23
- @output_stream << @encrypter.encrypt(@zlib_deflater.finish) until @zlib_deflater.finished?
24
- end
25
-
26
- attr_reader :size, :crc
27
- end
28
- end
29
-
30
- # Copyright (C) 2002, 2003 Thomas Sondergaard
31
- # rubyzip is free software; you can redistribute it and/or
32
- # modify it under the terms of the ruby license.
@@ -1,49 +0,0 @@
1
- module Zip
2
- class DOSTime < Time #:nodoc:all
3
-
4
- #MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
5
-
6
- # Register CX, the Time:
7
- # Bits 0-4 2 second increments (0-29)
8
- # Bits 5-10 minutes (0-59)
9
- # bits 11-15 hours (0-24)
10
-
11
- # Register DX, the Date:
12
- # Bits 0-4 day (1-31)
13
- # bits 5-8 month (1-12)
14
- # bits 9-15 year (four digit year minus 1980)
15
-
16
- def to_binary_dos_time
17
- (sec/2) +
18
- (min << 5) +
19
- (hour << 11)
20
- end
21
-
22
- def to_binary_dos_date
23
- (day) +
24
- (month << 5) +
25
- ((year - 1980) << 9)
26
- end
27
-
28
- # Dos time is only stored with two seconds accuracy
29
- def dos_equals(other)
30
- to_i/2 == other.to_i/2
31
- end
32
-
33
- def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
34
- second = 2 * (0b11111 & binaryDosTime)
35
- minute = (0b11111100000 & binaryDosTime) >> 5
36
- hour = (0b1111100000000000 & binaryDosTime) >> 11
37
- day = (0b11111 & binaryDosDate)
38
- month = (0b111100000 & binaryDosDate) >> 5
39
- year = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980
40
- begin
41
- self.local(year, month, day, hour, minute, second)
42
- end
43
- end
44
- end
45
- end
46
-
47
- # Copyright (C) 2002, 2003 Thomas Sondergaard
48
- # rubyzip is free software; you can redistribute it and/or
49
- # modify it under the terms of the ruby license.