Harbor Documentation

Constants

  • DEFLATED
  • FSTYPE_UNIX
  • LOCAL_ENTRY_SIGNATURE
  • CENTRAL_DIRECTORY_STATIC_HEADER_LENGTH

Attributes

  • comment [RW] (Not documented)
  • crc [RW] (Not documented)
  • file [RW] (Not documented)
  • compressed_size [RW] (Not documented)
  • uncompressed_size [RW] (Not documented)
  • local_header_offset [RW] (Not documented)

Public Class Methods

new(file)

       # File lib/harbor/zipped_io.rb, line 207
207:       def initialize(file)
208:         @file = file
209:       end

Public Instance Methods

binary_dos_date()

       # File lib/harbor/zipped_io.rb, line 211
211:       def binary_dos_date
212:         (time.day) + (time.month << 5) + ((time.year - 1980) << 9)
213:       end

binary_dos_time()

       # File lib/harbor/zipped_io.rb, line 215
215:       def binary_dos_time
216:         (time.sec / 2) + (time.min << 5) + (time.hour << 11)
217:       end

central_directory_header_size()

       # File lib/harbor/zipped_io.rb, line 219
219:       def central_directory_header_size
220:         CENTRAL_DIRECTORY_STATIC_HEADER_LENGTH + @file.name.size
221:       end

close()

       # File lib/harbor/zipped_io.rb, line 223
223:       def close
224:         @file.close unless @file.closed?
225:       end

name()

       # File lib/harbor/zipped_io.rb, line 227
227:       def name
228:         @file.name
229:       end

read_local_entry()

       # File lib/harbor/zipped_io.rb, line 235
235:       def read_local_entry
236:         generate unless @data
237:         @data
238:       end

size()

       # File lib/harbor/zipped_io.rb, line 240
240:       def size
241:         generate unless @data
242:         @data.size
243:       end

time()

       # File lib/harbor/zipped_io.rb, line 231
231:       def time
232:         @time ||= Time.now
233:       end

Private Instance Methods

generate()

       # File lib/harbor/zipped_io.rb, line 247
247:       def generate
248:         @data ||= ([
249:           ZipEntry::LOCAL_ENTRY_SIGNATURE,
250:           0,
251:           0,
252:           ZipEntry::DEFLATED,
253:           binary_dos_time,
254:           binary_dos_date,
255:           @crc, #crc
256:           @compressed_size,
257:           @uncompressed_size,
258:           @file.name.length,
259:           0 # extra length
260:         ].pack('VvvvvvVVVvv') << @file.name << "")
261:       end