vagrant-unbundled 2.2.6.1 → 2.2.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +11 -9
  3. data/vagrant.gemspec +1 -1
  4. data/vendor/bundle/ruby/2.6.0/bundler/gems/vagrant-spec-abfc34474d12/vagrant-spec.gemspec +1 -1
  5. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/CHANGELOG +79 -0
  6. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/MIT-LICENSE +21 -0
  7. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/README.rdoc +109 -0
  8. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/Rakefile +78 -0
  9. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/lib/erubi/capture_end.rb +52 -0
  10. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/lib/erubi.rb +211 -0
  11. data/vendor/bundle/ruby/2.6.0/gems/erubi-1.9.0/test/test.rb +780 -0
  12. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/README.md +354 -0
  13. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/Rakefile +18 -0
  14. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/TODO +15 -0
  15. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/central_directory.rb +208 -0
  16. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/compressor.rb +9 -0
  17. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/constants.rb +63 -0
  18. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/encryption.rb +11 -0
  19. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/null_encryption.rb +43 -0
  20. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/crypto/traditional_encryption.rb +99 -0
  21. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/decompressor.rb +13 -0
  22. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/deflater.rb +34 -0
  23. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/dos_time.rb +48 -0
  24. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/entry.rb +700 -0
  25. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/entry_set.rb +86 -0
  26. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/errors.rb +18 -0
  27. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/generic.rb +43 -0
  28. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/ntfs.rb +90 -0
  29. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/old_unix.rb +44 -0
  30. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/universal_time.rb +47 -0
  31. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/unix.rb +37 -0
  32. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/zip64.rb +68 -0
  33. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field/zip64_placeholder.rb +15 -0
  34. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/extra_field.rb +101 -0
  35. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/file.rb +443 -0
  36. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/filesystem.rb +627 -0
  37. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/inflater.rb +66 -0
  38. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/input_stream.rb +173 -0
  39. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras/abstract_input_stream.rb +111 -0
  40. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras/abstract_output_stream.rb +43 -0
  41. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/ioextras.rb +36 -0
  42. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_compressor.rb +15 -0
  43. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_decompressor.rb +27 -0
  44. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/null_input_stream.rb +10 -0
  45. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/output_stream.rb +189 -0
  46. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_compressor.rb +23 -0
  47. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/pass_thru_decompressor.rb +40 -0
  48. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/streamable_directory.rb +15 -0
  49. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/streamable_stream.rb +56 -0
  50. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip/version.rb +3 -0
  51. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/lib/zip.rb +71 -0
  52. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example.rb +81 -0
  53. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_filesystem.rb +31 -0
  54. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/example_recursive.rb +54 -0
  55. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/gtk_ruby_zip.rb +84 -0
  56. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/qtzip.rb +92 -0
  57. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/write_simple.rb +12 -0
  58. data/vendor/bundle/ruby/2.6.0/gems/rubyzip-2.0.0/samples/zipfind.rb +66 -0
  59. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/LICENSE +202 -0
  60. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/README.md +276 -0
  61. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/bin/rwinrm +90 -0
  62. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/connection.rb +84 -0
  63. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/connection_opts.rb +90 -0
  64. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/exceptions.rb +88 -0
  65. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/response_handler.rb +127 -0
  66. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/transport.rb +462 -0
  67. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/http/transport_factory.rb +64 -0
  68. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/output.rb +58 -0
  69. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/create_pipeline.xml.erb +167 -0
  70. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/fragment.rb +68 -0
  71. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -0
  72. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message.rb +128 -0
  73. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/base.rb +47 -0
  74. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/error_record.rb +66 -0
  75. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_host_call.rb +30 -0
  76. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_output.rb +48 -0
  77. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/pipeline_state.rb +38 -0
  78. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/runspacepool_host_call.rb +30 -0
  79. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/runspacepool_state.rb +37 -0
  80. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data/session_capability.rb +34 -0
  81. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_data.rb +40 -0
  82. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_defragmenter.rb +62 -0
  83. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_factory.rb +86 -0
  84. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/message_fragmenter.rb +58 -0
  85. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/powershell_output_decoder.rb +142 -0
  86. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/receive_response_reader.rb +95 -0
  87. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/session_capability.xml.erb +7 -0
  88. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/psrp/uuid.rb +39 -0
  89. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/base.rb +187 -0
  90. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/cmd.rb +63 -0
  91. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/power_shell.rb +206 -0
  92. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/retryable.rb +44 -0
  93. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/shells/shell_factory.rb +56 -0
  94. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/version.rb +5 -0
  95. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/base.rb +57 -0
  96. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/cleanup_command.rb +60 -0
  97. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/close_shell.rb +49 -0
  98. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command.rb +100 -0
  99. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command_output.rb +75 -0
  100. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/command_output_decoder.rb +54 -0
  101. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/configuration.rb +44 -0
  102. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/create_pipeline.rb +64 -0
  103. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/create_shell.rb +115 -0
  104. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/header.rb +213 -0
  105. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/init_runspace_pool.rb +96 -0
  106. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/iso8601_duration.rb +58 -0
  107. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/keep_alive.rb +66 -0
  108. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/receive_response_reader.rb +128 -0
  109. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/send_data.rb +66 -0
  110. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/soap.rb +49 -0
  111. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/wql_pull.rb +54 -0
  112. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/wql_query.rb +98 -0
  113. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm/wsmv/write_stdin.rb +86 -0
  114. data/vendor/bundle/ruby/2.6.0/gems/winrm-2.3.3/lib/winrm.rb +37 -0
  115. data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/LICENSE +202 -0
  116. data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/README.md +99 -0
  117. data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm/shells/elevated.rb +108 -0
  118. data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm-elevated/scripts/elevated_shell.ps1 +116 -0
  119. data/vendor/bundle/ruby/2.6.0/gems/winrm-elevated-1.1.2/lib/winrm-elevated.rb +17 -0
  120. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/LICENSE +202 -0
  121. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/README.md +82 -0
  122. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/bin/rwinrmcp +87 -0
  123. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/core/file_transporter.rb +569 -0
  124. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/core/tmp_zip.rb +178 -0
  125. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/exceptions.rb +29 -0
  126. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/file_manager.rb +158 -0
  127. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/check_files.ps1.erb +49 -0
  128. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/checksum.ps1.erb +13 -0
  129. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/create_dir.ps1.erb +6 -0
  130. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/delete.ps1.erb +6 -0
  131. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/download.ps1.erb +17 -0
  132. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/exists.ps1.erb +10 -0
  133. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/extract_files.ps1.erb +52 -0
  134. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs/scripts/scripts.rb +47 -0
  135. data/vendor/bundle/ruby/2.6.0/gems/winrm-fs-1.3.4/lib/winrm-fs.rb +29 -0
  136. data/vendor/bundle/ruby/2.6.0/specifications/erubi-1.9.0.gemspec +38 -0
  137. data/vendor/bundle/ruby/2.6.0/specifications/rubyzip-2.0.0.gemspec +45 -0
  138. data/vendor/bundle/ruby/2.6.0/specifications/winrm-2.3.3.gemspec +73 -0
  139. data/vendor/bundle/ruby/2.6.0/specifications/winrm-elevated-1.1.2.gemspec +50 -0
  140. data/vendor/bundle/ruby/2.6.0/specifications/winrm-fs-1.3.4.gemspec +58 -0
  141. data/version.txt +1 -1
  142. metadata +142 -6
@@ -0,0 +1,173 @@
1
+ module Zip
2
+ # InputStream is the basic class for reading zip entries in a
3
+ # zip file. It is possible to create a InputStream object directly,
4
+ # passing the zip file name to the constructor, but more often than not
5
+ # the InputStream will be obtained from a File (perhaps using the
6
+ # ZipFileSystem interface) object for a particular entry in the zip
7
+ # archive.
8
+ #
9
+ # A InputStream inherits IOExtras::AbstractInputStream in order
10
+ # to provide an IO-like interface for reading from a single zip
11
+ # entry. Beyond methods for mimicking an IO-object it contains
12
+ # the method get_next_entry for iterating through the entries of
13
+ # an archive. get_next_entry returns a Entry object that describes
14
+ # the zip entry the InputStream is currently reading from.
15
+ #
16
+ # Example that creates a zip archive with ZipOutputStream and reads it
17
+ # back again with a InputStream.
18
+ #
19
+ # require 'zip'
20
+ #
21
+ # Zip::OutputStream.open("my.zip") do |io|
22
+ #
23
+ # io.put_next_entry("first_entry.txt")
24
+ # io.write "Hello world!"
25
+ #
26
+ # io.put_next_entry("adir/first_entry.txt")
27
+ # io.write "Hello again!"
28
+ # end
29
+ #
30
+ #
31
+ # Zip::InputStream.open("my.zip") do |io|
32
+ #
33
+ # while (entry = io.get_next_entry)
34
+ # puts "Contents of #{entry.name}: '#{io.read}'"
35
+ # end
36
+ # end
37
+ #
38
+ # java.util.zip.ZipInputStream is the original inspiration for this
39
+ # class.
40
+
41
+ class InputStream
42
+ include ::Zip::IOExtras::AbstractInputStream
43
+
44
+ # Opens the indicated zip file. An exception is thrown
45
+ # if the specified offset in the specified filename is
46
+ # not a local zip entry header.
47
+ #
48
+ # @param context [String||IO||StringIO] file path or IO/StringIO object
49
+ # @param offset [Integer] offset in the IO/StringIO
50
+ def initialize(context, offset = 0, decrypter = nil)
51
+ super()
52
+ @archive_io = get_io(context, offset)
53
+ @decompressor = ::Zip::NullDecompressor
54
+ @decrypter = decrypter || ::Zip::NullDecrypter.new
55
+ @current_entry = nil
56
+ end
57
+
58
+ def close
59
+ @archive_io.close
60
+ end
61
+
62
+ # Returns a Entry object. It is necessary to call this
63
+ # method on a newly created InputStream before reading from
64
+ # the first entry in the archive. Returns nil when there are
65
+ # no more entries.
66
+ def get_next_entry
67
+ @archive_io.seek(@current_entry.next_header_offset, IO::SEEK_SET) if @current_entry
68
+ open_entry
69
+ end
70
+
71
+ # Rewinds the stream to the beginning of the current entry
72
+ def rewind
73
+ return if @current_entry.nil?
74
+ @lineno = 0
75
+ @pos = 0
76
+ @archive_io.seek(@current_entry.local_header_offset, IO::SEEK_SET)
77
+ open_entry
78
+ end
79
+
80
+ # Modeled after IO.sysread
81
+ def sysread(number_of_bytes = nil, buf = nil)
82
+ @decompressor.sysread(number_of_bytes, buf)
83
+ end
84
+
85
+ def eof
86
+ @output_buffer.empty? && @decompressor.eof
87
+ end
88
+
89
+ alias :eof? eof
90
+
91
+ class << self
92
+ # Same as #initialize but if a block is passed the opened
93
+ # stream is passed to the block and closed when the block
94
+ # returns.
95
+ def open(filename_or_io, offset = 0, decrypter = nil)
96
+ zio = new(filename_or_io, offset, decrypter)
97
+ return zio unless block_given?
98
+ begin
99
+ yield zio
100
+ ensure
101
+ zio.close if zio
102
+ end
103
+ end
104
+
105
+ def open_buffer(filename_or_io, offset = 0)
106
+ puts 'open_buffer is deprecated!!! Use open instead!'
107
+ open(filename_or_io, offset)
108
+ end
109
+ end
110
+
111
+ protected
112
+
113
+ def get_io(io_or_file, offset = 0)
114
+ if io_or_file.respond_to?(:seek)
115
+ io = io_or_file.dup
116
+ io.seek(offset, ::IO::SEEK_SET)
117
+ io
118
+ else
119
+ file = ::File.open(io_or_file, 'rb')
120
+ file.seek(offset, ::IO::SEEK_SET)
121
+ file
122
+ end
123
+ end
124
+
125
+ def open_entry
126
+ @current_entry = ::Zip::Entry.read_local_entry(@archive_io)
127
+ if @current_entry && @current_entry.gp_flags & 1 == 1 && @decrypter.is_a?(NullEncrypter)
128
+ raise Error, 'password required to decode zip file'
129
+ end
130
+ if @current_entry && @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 \
131
+ && @current_entry.compressed_size == 0 \
132
+ && @current_entry.size == 0 && !@complete_entry
133
+ raise GPFBit3Error,
134
+ 'General purpose flag Bit 3 is set so not possible to get proper info from local header.' \
135
+ 'Please use ::Zip::File instead of ::Zip::InputStream'
136
+ end
137
+ @decompressor = get_decompressor
138
+ flush
139
+ @current_entry
140
+ end
141
+
142
+ def get_decompressor
143
+ if @current_entry.nil?
144
+ ::Zip::NullDecompressor
145
+ elsif @current_entry.compression_method == ::Zip::Entry::STORED
146
+ if @current_entry.gp_flags & 8 == 8 && @current_entry.crc == 0 && @current_entry.size == 0 && @complete_entry
147
+ ::Zip::PassThruDecompressor.new(@archive_io, @complete_entry.size)
148
+ else
149
+ ::Zip::PassThruDecompressor.new(@archive_io, @current_entry.size)
150
+ end
151
+ elsif @current_entry.compression_method == ::Zip::Entry::DEFLATED
152
+ header = @archive_io.read(@decrypter.header_bytesize)
153
+ @decrypter.reset!(header)
154
+ ::Zip::Inflater.new(@archive_io, @decrypter)
155
+ else
156
+ raise ::Zip::CompressionMethodError,
157
+ "Unsupported compression method #{@current_entry.compression_method}"
158
+ end
159
+ end
160
+
161
+ def produce_input
162
+ @decompressor.produce_input
163
+ end
164
+
165
+ def input_finished?
166
+ @decompressor.input_finished?
167
+ end
168
+ end
169
+ end
170
+
171
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
172
+ # rubyzip is free software; you can redistribute it and/or
173
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,111 @@
1
+ module Zip
2
+ module IOExtras
3
+ # Implements many of the convenience methods of IO
4
+ # such as gets, getc, readline and readlines
5
+ # depends on: input_finished?, produce_input and read
6
+ module AbstractInputStream
7
+ include Enumerable
8
+ include FakeIO
9
+
10
+ def initialize
11
+ super
12
+ @lineno = 0
13
+ @pos = 0
14
+ @output_buffer = ''
15
+ end
16
+
17
+ attr_accessor :lineno
18
+ attr_reader :pos
19
+
20
+ def read(number_of_bytes = nil, buf = '')
21
+ tbuf = if @output_buffer.bytesize > 0
22
+ if number_of_bytes <= @output_buffer.bytesize
23
+ @output_buffer.slice!(0, number_of_bytes)
24
+ else
25
+ number_of_bytes -= @output_buffer.bytesize if number_of_bytes
26
+ rbuf = sysread(number_of_bytes, buf)
27
+ out = @output_buffer
28
+ out << rbuf if rbuf
29
+ @output_buffer = ''
30
+ out
31
+ end
32
+ else
33
+ sysread(number_of_bytes, buf)
34
+ end
35
+
36
+ if tbuf.nil? || tbuf.empty?
37
+ return nil if number_of_bytes
38
+ return ''
39
+ end
40
+
41
+ @pos += tbuf.length
42
+
43
+ if buf
44
+ buf.replace(tbuf)
45
+ else
46
+ buf = tbuf
47
+ end
48
+ buf
49
+ end
50
+
51
+ def readlines(a_sep_string = $/)
52
+ ret_val = []
53
+ each_line(a_sep_string) { |line| ret_val << line }
54
+ ret_val
55
+ end
56
+
57
+ def gets(a_sep_string = $/, number_of_bytes = nil)
58
+ @lineno = @lineno.next
59
+
60
+ if number_of_bytes.respond_to?(:to_int)
61
+ number_of_bytes = number_of_bytes.to_int
62
+ a_sep_string = a_sep_string.to_str if a_sep_string
63
+ elsif a_sep_string.respond_to?(:to_int)
64
+ number_of_bytes = a_sep_string.to_int
65
+ a_sep_string = $/
66
+ else
67
+ number_of_bytes = nil
68
+ a_sep_string = a_sep_string.to_str if a_sep_string
69
+ end
70
+
71
+ return read(number_of_bytes) if a_sep_string.nil?
72
+ a_sep_string = "#{$/}#{$/}" if a_sep_string.empty?
73
+
74
+ buffer_index = 0
75
+ over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
76
+ while (match_index = @output_buffer.index(a_sep_string, buffer_index)).nil? && !over_limit
77
+ buffer_index = [buffer_index, @output_buffer.bytesize - a_sep_string.bytesize].max
78
+ return @output_buffer.empty? ? nil : flush if input_finished?
79
+ @output_buffer << produce_input
80
+ over_limit = (number_of_bytes && @output_buffer.bytesize >= number_of_bytes)
81
+ end
82
+ sep_index = [match_index + a_sep_string.bytesize, number_of_bytes || @output_buffer.bytesize].min
83
+ @pos += sep_index
84
+ @output_buffer.slice!(0...sep_index)
85
+ end
86
+
87
+ def ungetc(byte)
88
+ @output_buffer = byte.chr + @output_buffer
89
+ end
90
+
91
+ def flush
92
+ ret_val = @output_buffer
93
+ @output_buffer = ''
94
+ ret_val
95
+ end
96
+
97
+ def readline(a_sep_string = $/)
98
+ ret_val = gets(a_sep_string)
99
+ raise EOFError unless ret_val
100
+ ret_val
101
+ end
102
+
103
+ def each_line(a_sep_string = $/)
104
+ yield readline(a_sep_string) while true
105
+ rescue EOFError
106
+ end
107
+
108
+ alias_method :each, :each_line
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,43 @@
1
+ module Zip
2
+ module IOExtras
3
+ # Implements many of the output convenience methods of IO.
4
+ # relies on <<
5
+ module AbstractOutputStream
6
+ include FakeIO
7
+
8
+ def write(data)
9
+ self << data
10
+ data.to_s.bytesize
11
+ end
12
+
13
+ def print(*params)
14
+ self << params.join($,) << $\.to_s
15
+ end
16
+
17
+ def printf(a_format_string, *params)
18
+ self << format(a_format_string, *params)
19
+ end
20
+
21
+ def putc(an_object)
22
+ self << case an_object
23
+ when Integer
24
+ an_object.chr
25
+ when String
26
+ an_object
27
+ else
28
+ raise TypeError, 'putc: Only Integer and String supported'
29
+ end
30
+ an_object
31
+ end
32
+
33
+ def puts(*params)
34
+ params << "\n" if params.empty?
35
+ params.flatten.each do |element|
36
+ val = element.to_s
37
+ self << val
38
+ self << "\n" unless val[-1, 1] == "\n"
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module Zip
2
+ module IOExtras #:nodoc:
3
+ CHUNK_SIZE = 131_072
4
+
5
+ RANGE_ALL = 0..-1
6
+
7
+ class << self
8
+ def copy_stream(ostream, istream)
9
+ ostream.write(istream.read(CHUNK_SIZE, '')) until istream.eof?
10
+ end
11
+
12
+ def copy_stream_n(ostream, istream, nbytes)
13
+ toread = nbytes
14
+ while toread > 0 && !istream.eof?
15
+ tr = toread > CHUNK_SIZE ? CHUNK_SIZE : toread
16
+ ostream.write(istream.read(tr, ''))
17
+ toread -= tr
18
+ end
19
+ end
20
+ end
21
+
22
+ # Implements kind_of? in order to pretend to be an IO object
23
+ module FakeIO
24
+ def kind_of?(object)
25
+ object == IO || super
26
+ end
27
+ end
28
+ end # IOExtras namespace module
29
+ end
30
+
31
+ require 'zip/ioextras/abstract_input_stream'
32
+ require 'zip/ioextras/abstract_output_stream'
33
+
34
+ # Copyright (C) 2002-2004 Thomas Sondergaard
35
+ # rubyzip is free software; you can redistribute it and/or
36
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,15 @@
1
+ module Zip
2
+ class NullCompressor < Compressor #:nodoc:all
3
+ include Singleton
4
+
5
+ def <<(_data)
6
+ raise IOError, 'closed stream'
7
+ end
8
+
9
+ attr_reader :size, :compressed_size
10
+ end
11
+ end
12
+
13
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
14
+ # rubyzip is free software; you can redistribute it and/or
15
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,27 @@
1
+ module Zip
2
+ module NullDecompressor #:nodoc:all
3
+ module_function
4
+
5
+ def sysread(_numberOfBytes = nil, _buf = nil)
6
+ nil
7
+ end
8
+
9
+ def produce_input
10
+ nil
11
+ end
12
+
13
+ def input_finished?
14
+ true
15
+ end
16
+
17
+ def eof
18
+ true
19
+ end
20
+
21
+ alias eof? eof
22
+ end
23
+ end
24
+
25
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
26
+ # rubyzip is free software; you can redistribute it and/or
27
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,10 @@
1
+ module Zip
2
+ module NullInputStream #:nodoc:all
3
+ include ::Zip::NullDecompressor
4
+ include ::Zip::IOExtras::AbstractInputStream
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.
@@ -0,0 +1,189 @@
1
+ module Zip
2
+ # ZipOutputStream is the basic class for writing zip files. It is
3
+ # possible to create a ZipOutputStream object directly, passing
4
+ # the zip file name to the constructor, but more often than not
5
+ # the ZipOutputStream will be obtained from a ZipFile (perhaps using the
6
+ # ZipFileSystem interface) object for a particular entry in the zip
7
+ # archive.
8
+ #
9
+ # A ZipOutputStream inherits IOExtras::AbstractOutputStream in order
10
+ # to provide an IO-like interface for writing to a single zip
11
+ # entry. Beyond methods for mimicking an IO-object it contains
12
+ # the method put_next_entry that closes the current entry
13
+ # and creates a new.
14
+ #
15
+ # Please refer to ZipInputStream for example code.
16
+ #
17
+ # java.util.zip.ZipOutputStream is the original inspiration for this
18
+ # class.
19
+
20
+ class OutputStream
21
+ include ::Zip::IOExtras::AbstractOutputStream
22
+
23
+ attr_accessor :comment
24
+
25
+ # Opens the indicated zip file. If a file with that name already
26
+ # exists it will be overwritten.
27
+ def initialize(file_name, stream = false, encrypter = nil)
28
+ super()
29
+ @file_name = file_name
30
+ @output_stream = if stream
31
+ iostream = @file_name.dup
32
+ iostream.reopen(@file_name)
33
+ iostream.rewind
34
+ iostream
35
+ else
36
+ ::File.new(@file_name, 'wb')
37
+ end
38
+ @entry_set = ::Zip::EntrySet.new
39
+ @compressor = ::Zip::NullCompressor.instance
40
+ @encrypter = encrypter || ::Zip::NullEncrypter.new
41
+ @closed = false
42
+ @current_entry = nil
43
+ @comment = nil
44
+ end
45
+
46
+ # Same as #initialize but if a block is passed the opened
47
+ # stream is passed to the block and closed when the block
48
+ # returns.
49
+ class << self
50
+ def open(file_name, encrypter = nil)
51
+ return new(file_name) unless block_given?
52
+ zos = new(file_name, false, encrypter)
53
+ yield zos
54
+ ensure
55
+ zos.close if zos
56
+ end
57
+
58
+ # Same as #open but writes to a filestream instead
59
+ def write_buffer(io = ::StringIO.new(''), encrypter = nil)
60
+ zos = new(io, true, encrypter)
61
+ yield zos
62
+ zos.close_buffer
63
+ end
64
+ end
65
+
66
+ # Closes the stream and writes the central directory to the zip file
67
+ def close
68
+ return if @closed
69
+ finalize_current_entry
70
+ update_local_headers
71
+ write_central_directory
72
+ @output_stream.close
73
+ @closed = true
74
+ end
75
+
76
+ # Closes the stream and writes the central directory to the zip file
77
+ def close_buffer
78
+ return @output_stream if @closed
79
+ finalize_current_entry
80
+ update_local_headers
81
+ write_central_directory
82
+ @closed = true
83
+ @output_stream
84
+ end
85
+
86
+ # Closes the current entry and opens a new for writing.
87
+ # +entry+ can be a ZipEntry object or a string.
88
+ def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression)
89
+ raise Error, 'zip stream is closed' if @closed
90
+ new_entry = if entry_name.kind_of?(Entry)
91
+ entry_name
92
+ else
93
+ Entry.new(@file_name, entry_name.to_s)
94
+ end
95
+ new_entry.comment = comment unless comment.nil?
96
+ unless extra.nil?
97
+ new_entry.extra = extra.is_a?(ExtraField) ? extra : ExtraField.new(extra.to_s)
98
+ end
99
+ new_entry.compression_method = compression_method unless compression_method.nil?
100
+ init_next_entry(new_entry, level)
101
+ @current_entry = new_entry
102
+ end
103
+
104
+ def copy_raw_entry(entry)
105
+ entry = entry.dup
106
+ raise Error, 'zip stream is closed' if @closed
107
+ raise Error, 'entry is not a ZipEntry' unless entry.is_a?(Entry)
108
+ finalize_current_entry
109
+ @entry_set << entry
110
+ src_pos = entry.local_header_offset
111
+ entry.write_local_entry(@output_stream)
112
+ @compressor = NullCompressor.instance
113
+ entry.get_raw_input_stream do |is|
114
+ is.seek(src_pos, IO::SEEK_SET)
115
+ ::Zip::Entry.read_local_entry(is)
116
+ IOExtras.copy_stream_n(@output_stream, is, entry.compressed_size)
117
+ end
118
+ @compressor = NullCompressor.instance
119
+ @current_entry = nil
120
+ end
121
+
122
+ private
123
+
124
+ def finalize_current_entry
125
+ return unless @current_entry
126
+ finish
127
+ @current_entry.compressed_size = @output_stream.tell - @current_entry.local_header_offset - @current_entry.calculate_local_header_size
128
+ @current_entry.size = @compressor.size
129
+ @current_entry.crc = @compressor.crc
130
+ @output_stream << @encrypter.data_descriptor(@current_entry.crc, @current_entry.compressed_size, @current_entry.size)
131
+ @current_entry.gp_flags |= @encrypter.gp_flags
132
+ @current_entry = nil
133
+ @compressor = ::Zip::NullCompressor.instance
134
+ end
135
+
136
+ def init_next_entry(entry, level = Zip.default_compression)
137
+ finalize_current_entry
138
+ @entry_set << entry
139
+ entry.write_local_entry(@output_stream)
140
+ @encrypter.reset!
141
+ @output_stream << @encrypter.header(entry.mtime)
142
+ @compressor = get_compressor(entry, level)
143
+ end
144
+
145
+ def get_compressor(entry, level)
146
+ case entry.compression_method
147
+ when Entry::DEFLATED then
148
+ ::Zip::Deflater.new(@output_stream, level, @encrypter)
149
+ when Entry::STORED then
150
+ ::Zip::PassThruCompressor.new(@output_stream)
151
+ else
152
+ raise ::Zip::CompressionMethodError,
153
+ "Invalid compression method: '#{entry.compression_method}'"
154
+ end
155
+ end
156
+
157
+ def update_local_headers
158
+ pos = @output_stream.pos
159
+ @entry_set.each do |entry|
160
+ @output_stream.pos = entry.local_header_offset
161
+ entry.write_local_entry(@output_stream, true)
162
+ end
163
+ @output_stream.pos = pos
164
+ end
165
+
166
+ def write_central_directory
167
+ cdir = CentralDirectory.new(@entry_set, @comment)
168
+ cdir.write_to_stream(@output_stream)
169
+ end
170
+
171
+ protected
172
+
173
+ def finish
174
+ @compressor.finish
175
+ end
176
+
177
+ public
178
+
179
+ # Modeled after IO.<<
180
+ def <<(data)
181
+ @compressor << data
182
+ self
183
+ end
184
+ end
185
+ end
186
+
187
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
188
+ # rubyzip is free software; you can redistribute it and/or
189
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,23 @@
1
+ module Zip
2
+ class PassThruCompressor < Compressor #:nodoc:all
3
+ def initialize(outputStream)
4
+ super()
5
+ @output_stream = outputStream
6
+ @crc = Zlib.crc32
7
+ @size = 0
8
+ end
9
+
10
+ def <<(data)
11
+ val = data.to_s
12
+ @crc = Zlib.crc32(val, @crc)
13
+ @size += val.bytesize
14
+ @output_stream << val
15
+ end
16
+
17
+ attr_reader :size, :crc
18
+ end
19
+ end
20
+
21
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
22
+ # rubyzip is free software; you can redistribute it and/or
23
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,40 @@
1
+ module Zip
2
+ class PassThruDecompressor < Decompressor #:nodoc:all
3
+ def initialize(input_stream, chars_to_read)
4
+ super(input_stream)
5
+ @chars_to_read = chars_to_read
6
+ @read_so_far = 0
7
+ @has_returned_empty_string = false
8
+ end
9
+
10
+ def sysread(number_of_bytes = nil, buf = '')
11
+ if input_finished?
12
+ has_returned_empty_string_val = @has_returned_empty_string
13
+ @has_returned_empty_string = true
14
+ return '' unless has_returned_empty_string_val
15
+ return
16
+ end
17
+
18
+ if number_of_bytes.nil? || @read_so_far + number_of_bytes > @chars_to_read
19
+ number_of_bytes = @chars_to_read - @read_so_far
20
+ end
21
+ @read_so_far += number_of_bytes
22
+ @input_stream.read(number_of_bytes, buf)
23
+ end
24
+
25
+ def produce_input
26
+ sysread(::Zip::Decompressor::CHUNK_SIZE)
27
+ end
28
+
29
+ def input_finished?
30
+ @read_so_far >= @chars_to_read
31
+ end
32
+
33
+ alias eof input_finished?
34
+ alias eof? input_finished?
35
+ end
36
+ end
37
+
38
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
39
+ # rubyzip is free software; you can redistribute it and/or
40
+ # modify it under the terms of the ruby license.
@@ -0,0 +1,15 @@
1
+ module Zip
2
+ class StreamableDirectory < Entry
3
+ def initialize(zipfile, entry, srcPath = nil, permissionInt = nil)
4
+ super(zipfile, entry)
5
+
6
+ @ftype = :directory
7
+ entry.get_extra_attributes_from_path(srcPath) if srcPath
8
+ @unix_perms = permissionInt if permissionInt
9
+ end
10
+ end
11
+ end
12
+
13
+ # Copyright (C) 2002, 2003 Thomas Sondergaard
14
+ # rubyzip is free software; you can redistribute it and/or
15
+ # modify it under the terms of the ruby license.