rubyzip 2.3.1 → 3.0.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changelog.md +368 -0
- data/README.md +122 -39
- data/Rakefile +11 -7
- data/lib/zip/central_directory.rb +164 -118
- data/lib/zip/compressor.rb +3 -1
- data/lib/zip/constants.rb +25 -21
- data/lib/zip/crypto/decrypted_io.rb +3 -1
- data/lib/zip/crypto/encryption.rb +4 -2
- data/lib/zip/crypto/null_encryption.rb +5 -3
- data/lib/zip/crypto/traditional_encryption.rb +5 -3
- data/lib/zip/decompressor.rb +4 -3
- data/lib/zip/deflater.rb +10 -8
- data/lib/zip/dirtyable.rb +32 -0
- data/lib/zip/dos_time.rb +41 -5
- data/lib/zip/entry.rb +273 -170
- data/lib/zip/entry_set.rb +9 -7
- data/lib/zip/errors.rb +115 -16
- data/lib/zip/extra_field/generic.rb +3 -10
- data/lib/zip/extra_field/ntfs.rb +4 -2
- data/lib/zip/extra_field/old_unix.rb +3 -1
- data/lib/zip/extra_field/universal_time.rb +3 -1
- data/lib/zip/extra_field/unix.rb +5 -3
- data/lib/zip/extra_field/unknown.rb +33 -0
- data/lib/zip/extra_field/zip64.rb +12 -5
- data/lib/zip/extra_field.rb +15 -21
- data/lib/zip/file.rb +152 -221
- data/lib/zip/file_split.rb +97 -0
- data/lib/zip/filesystem/dir.rb +86 -0
- data/lib/zip/filesystem/directory_iterator.rb +48 -0
- data/lib/zip/filesystem/file.rb +262 -0
- data/lib/zip/filesystem/file_stat.rb +110 -0
- data/lib/zip/filesystem/zip_file_name_mapper.rb +81 -0
- data/lib/zip/filesystem.rb +26 -595
- data/lib/zip/inflater.rb +6 -4
- data/lib/zip/input_stream.rb +43 -25
- data/lib/zip/ioextras/abstract_input_stream.rb +13 -8
- data/lib/zip/ioextras/abstract_output_stream.rb +5 -3
- data/lib/zip/ioextras.rb +6 -6
- data/lib/zip/null_compressor.rb +3 -1
- data/lib/zip/null_decompressor.rb +3 -1
- data/lib/zip/null_input_stream.rb +3 -1
- data/lib/zip/output_stream.rb +45 -39
- data/lib/zip/pass_thru_compressor.rb +3 -1
- data/lib/zip/pass_thru_decompressor.rb +4 -2
- data/lib/zip/streamable_directory.rb +3 -1
- data/lib/zip/streamable_stream.rb +3 -0
- data/lib/zip/version.rb +3 -1
- data/lib/zip.rb +15 -22
- data/rubyzip.gemspec +38 -0
- data/samples/example.rb +8 -3
- data/samples/example_filesystem.rb +2 -1
- data/samples/example_recursive.rb +3 -1
- data/samples/gtk_ruby_zip.rb +4 -2
- data/samples/qtzip.rb +6 -5
- data/samples/write_simple.rb +1 -0
- data/samples/zipfind.rb +1 -0
- metadata +83 -35
- data/TODO +0 -15
- data/lib/zip/extra_field/zip64_placeholder.rb +0 -15
data/lib/zip/dos_time.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
1
5
|
module Zip
|
2
|
-
class DOSTime < Time
|
6
|
+
class DOSTime < Time # :nodoc:all
|
3
7
|
# MS-DOS File Date and Time format as used in Interrupt 21H Function 57H:
|
4
8
|
|
5
9
|
# Register CX, the Time:
|
@@ -24,9 +28,16 @@ module Zip
|
|
24
28
|
((year - 1980) << 9)
|
25
29
|
end
|
26
30
|
|
27
|
-
# Dos time is only stored with two seconds accuracy
|
28
31
|
def dos_equals(other)
|
29
|
-
|
32
|
+
warn 'Zip::DOSTime#dos_equals is deprecated. Use `==` instead.'
|
33
|
+
self == other
|
34
|
+
end
|
35
|
+
|
36
|
+
# Dos time is only stored with two seconds accuracy.
|
37
|
+
def <=>(other)
|
38
|
+
return unless other.kind_of?(Time)
|
39
|
+
|
40
|
+
(to_i / 2) <=> (other.to_i / 2)
|
30
41
|
end
|
31
42
|
|
32
43
|
# Create a DOSTime instance from a vanilla Time instance.
|
@@ -41,9 +52,34 @@ module Zip
|
|
41
52
|
day = (0b11111 & bin_dos_date)
|
42
53
|
month = (0b111100000 & bin_dos_date) >> 5
|
43
54
|
year = ((0b1111111000000000 & bin_dos_date) >> 9) + 1980
|
44
|
-
|
45
|
-
|
55
|
+
|
56
|
+
local(year, month, day, hour, minute, second)
|
57
|
+
end
|
58
|
+
|
59
|
+
if defined? JRUBY_VERSION && Gem::Version.new(JRUBY_VERSION) < '9.2.18.0'
|
60
|
+
module JRubyCMP # :nodoc:
|
61
|
+
def ==(other)
|
62
|
+
(self <=> other).zero?
|
63
|
+
end
|
64
|
+
|
65
|
+
def <(other)
|
66
|
+
(self <=> other).negative?
|
67
|
+
end
|
68
|
+
|
69
|
+
def <=(other)
|
70
|
+
(self <=> other) <= 0
|
71
|
+
end
|
72
|
+
|
73
|
+
def >(other)
|
74
|
+
(self <=> other).positive?
|
75
|
+
end
|
76
|
+
|
77
|
+
def >=(other)
|
78
|
+
(self <=> other) >= 0
|
79
|
+
end
|
46
80
|
end
|
81
|
+
|
82
|
+
include JRubyCMP
|
47
83
|
end
|
48
84
|
end
|
49
85
|
end
|