Module: Zip

Extended by:
Zip
Included in:
Zip
Defined in:
lib/zip.rb,
lib/zip/file.rb,
lib/zip/entry.rb,
lib/zip/errors.rb,
lib/zip/version.rb,
lib/zip/deflater.rb,
lib/zip/dos_time.rb,
lib/zip/inflater.rb,
lib/zip/ioextras.rb,
lib/zip/constants.rb,
lib/zip/entry_set.rb,
lib/zip/compressor.rb,
lib/zip/filesystem.rb,
lib/zip/extra_field.rb,
lib/zip/decompressor.rb,
lib/zip/input_stream.rb,
lib/zip/output_stream.rb,
lib/zip/null_compressor.rb,
lib/zip/extra_field/ntfs.rb,
lib/zip/extra_field/unix.rb,
lib/zip/central_directory.rb,
lib/zip/crypto/encryption.rb,
lib/zip/extra_field/zip64.rb,
lib/zip/null_decompressor.rb,
lib/zip/null_input_stream.rb,
lib/zip/streamable_stream.rb,
lib/zip/crypto/decrypted_io.rb,
lib/zip/extra_field/generic.rb,
lib/zip/extra_field/old_unix.rb,
lib/zip/pass_thru_compressor.rb,
lib/zip/streamable_directory.rb,
lib/zip/crypto/null_encryption.rb,
lib/zip/pass_thru_decompressor.rb,
lib/zip/extra_field/universal_time.rb,
lib/zip/crypto/traditional_encryption.rb,
lib/zip/extra_field/zip64_placeholder.rb,
lib/zip/ioextras/abstract_input_stream.rb,
lib/zip/ioextras/abstract_output_stream.rb

Defined Under Namespace

Modules: FileSystem, IOExtras, NullDecompressor, NullEncryption, NullInputStream, TraditionalEncryption Classes: CentralDirectory, CompressionMethodError, Compressor, DOSTime, DecompressionError, Decompressor, DecryptedIo, Decrypter, Deflater, DestinationFileExistsError, Encrypter, Entry, EntryExistsError, EntryNameError, EntrySet, EntrySizeError, Error, ExtraField, File, GPFBit3Error, Inflater, InputStream, InternalError, NullCompressor, NullDecrypter, NullEncrypter, OutputStream, PassThruCompressor, PassThruDecompressor, StreamableDirectory, StreamableStream, TraditionalDecrypter, TraditionalEncrypter

Constant Summary collapse

ZipError =

Backwards compatibility with v1 (delete in v2)

Error
ZipEntryExistsError =
EntryExistsError
ZipDestinationFileExistsError =
DestinationFileExistsError
ZipCompressionMethodError =
CompressionMethodError
ZipEntryNameError =
EntryNameError
ZipInternalError =
InternalError
VERSION =
'2.3.2'
RUNNING_ON_WINDOWS =
RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/i
CENTRAL_DIRECTORY_ENTRY_SIGNATURE =
0x02014b50
CDIR_ENTRY_STATIC_HEADER_LENGTH =
46
LOCAL_ENTRY_SIGNATURE =
0x04034b50
LOCAL_ENTRY_STATIC_HEADER_LENGTH =
30
LOCAL_ENTRY_TRAILING_DESCRIPTOR_LENGTH =
4 + 4 + 4
VERSION_MADE_BY =

this library’s version

52
VERSION_NEEDED_TO_EXTRACT =
20
VERSION_NEEDED_TO_EXTRACT_ZIP64 =
45
FILE_TYPE_FILE =
0o10
FILE_TYPE_DIR =
0o04
0o12
FSTYPE_FAT =
0
FSTYPE_AMIGA =
1
FSTYPE_VMS =
2
FSTYPE_UNIX =
3
FSTYPE_VM_CMS =
4
FSTYPE_ATARI =
5
FSTYPE_HPFS =
6
FSTYPE_MAC =
7
FSTYPE_Z_SYSTEM =
8
FSTYPE_CPM =
9
FSTYPE_TOPS20 =
10
FSTYPE_NTFS =
11
FSTYPE_QDOS =
12
FSTYPE_ACORN =
13
FSTYPE_VFAT =
14
FSTYPE_MVS =
15
FSTYPE_BEOS =
16
FSTYPE_TANDEM =
17
FSTYPE_THEOS =
18
FSTYPE_MAC_OSX =
19
FSTYPE_ATHEOS =
30
FSTYPES =
{
  FSTYPE_FAT      => 'FAT'.freeze,
  FSTYPE_AMIGA    => 'Amiga'.freeze,
  FSTYPE_VMS      => 'VMS (Vax or Alpha AXP)'.freeze,
  FSTYPE_UNIX     => 'Unix'.freeze,
  FSTYPE_VM_CMS   => 'VM/CMS'.freeze,
  FSTYPE_ATARI    => 'Atari ST'.freeze,
  FSTYPE_HPFS     => 'OS/2 or NT HPFS'.freeze,
  FSTYPE_MAC      => 'Macintosh'.freeze,
  FSTYPE_Z_SYSTEM => 'Z-System'.freeze,
  FSTYPE_CPM      => 'CP/M'.freeze,
  FSTYPE_TOPS20   => 'TOPS-20'.freeze,
  FSTYPE_NTFS     => 'NTFS'.freeze,
  FSTYPE_QDOS     => 'SMS/QDOS'.freeze,
  FSTYPE_ACORN    => 'Acorn RISC OS'.freeze,
  FSTYPE_VFAT     => 'Win32 VFAT'.freeze,
  FSTYPE_MVS      => 'MVS'.freeze,
  FSTYPE_BEOS     => 'BeOS'.freeze,
  FSTYPE_TANDEM   => 'Tandem NSK'.freeze,
  FSTYPE_THEOS    => 'Theos'.freeze,
  FSTYPE_MAC_OSX  => 'Mac OS/X (Darwin)'.freeze,
  FSTYPE_ATHEOS   => 'AtheOS'.freeze
}.freeze
COMPRESSION_METHOD_STORE =
0
COMPRESSION_METHOD_SHRINK =
1
COMPRESSION_METHOD_REDUCE_1 =
2
COMPRESSION_METHOD_REDUCE_2 =
3
COMPRESSION_METHOD_REDUCE_3 =
4
COMPRESSION_METHOD_REDUCE_4 =
5
COMPRESSION_METHOD_IMPLODE =
6
COMPRESSION_METHOD_DEFLATE =

RESERVED = 7

8
COMPRESSION_METHOD_DEFLATE_64 =
9
COMPRESSION_METHOD_PKWARE_DCLI =
10
COMPRESSION_METHOD_BZIP2 =

RESERVED = 11

12
COMPRESSION_METHOD_LZMA =

RESERVED = 13

14
COMPRESSION_METHOD_IBM_CMPSC =

RESERVED = 15

16
COMPRESSION_METHOD_IBM_TERSE =

RESERVED = 17

18
COMPRESSION_METHOD_IBM_LZ77 =
19
COMPRESSION_METHOD_JPEG =
96
COMPRESSION_METHOD_WAVPACK =
97
COMPRESSION_METHOD_PPMD =
98
COMPRESSION_METHOD_AES =
99
COMPRESSION_METHODS =
{
  COMPRESSION_METHOD_STORE       => 'Store (no compression)',
  COMPRESSION_METHOD_SHRINK      => 'Shrink',
  COMPRESSION_METHOD_REDUCE_1    => 'Reduce with compression factor 1',
  COMPRESSION_METHOD_REDUCE_2    => 'Reduce with compression factor 2',
  COMPRESSION_METHOD_REDUCE_3    => 'Reduce with compression factor 3',
  COMPRESSION_METHOD_REDUCE_4    => 'Reduce with compression factor 4',
  COMPRESSION_METHOD_IMPLODE     => 'Implode',
  # RESERVED = 7
  COMPRESSION_METHOD_DEFLATE     => 'Deflate',
  COMPRESSION_METHOD_DEFLATE_64  => 'Deflate64(tm)',
  COMPRESSION_METHOD_PKWARE_DCLI => 'PKWARE Data Compression Library Imploding (old IBM TERSE)',
  # RESERVED = 11
  COMPRESSION_METHOD_BZIP2       => 'BZIP2',
  # RESERVED = 13
  COMPRESSION_METHOD_LZMA        => 'LZMA',
  # RESERVED = 15
  COMPRESSION_METHOD_IBM_CMPSC   => 'IBM z/OS CMPSC Compression',
  # RESERVED = 17
  COMPRESSION_METHOD_IBM_TERSE   => 'IBM TERSE (new)',
  COMPRESSION_METHOD_IBM_LZ77    => 'IBM LZ77 z Architecture (PFS)',
  COMPRESSION_METHOD_JPEG        => 'JPEG variant',
  COMPRESSION_METHOD_WAVPACK     => 'WavPack compressed data',
  COMPRESSION_METHOD_PPMD        => 'PPMd version I, Rev 1',
  COMPRESSION_METHOD_AES         => 'AES encryption'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#case_insensitive_matchObject

Returns the value of attribute case_insensitive_match.



38
39
40
# File 'lib/zip.rb', line 38

def case_insensitive_match
  @case_insensitive_match
end

#continue_on_exists_procObject

Returns the value of attribute continue_on_exists_proc.



38
39
40
# File 'lib/zip.rb', line 38

def continue_on_exists_proc
  @continue_on_exists_proc
end

#default_compressionObject

Returns the value of attribute default_compression.



38
39
40
# File 'lib/zip.rb', line 38

def default_compression
  @default_compression
end

#force_entry_names_encodingObject

Returns the value of attribute force_entry_names_encoding.



38
39
40
# File 'lib/zip.rb', line 38

def force_entry_names_encoding
  @force_entry_names_encoding
end

#on_exists_procObject

Returns the value of attribute on_exists_proc.



38
39
40
# File 'lib/zip.rb', line 38

def on_exists_proc
  @on_exists_proc
end

#sort_entriesObject

Returns the value of attribute sort_entries.



38
39
40
# File 'lib/zip.rb', line 38

def sort_entries
  @sort_entries
end

#unicode_namesObject

Returns the value of attribute unicode_names.



38
39
40
# File 'lib/zip.rb', line 38

def unicode_names
  @unicode_names
end

#validate_entry_sizesObject

Returns the value of attribute validate_entry_sizes.



38
39
40
# File 'lib/zip.rb', line 38

def validate_entry_sizes
  @validate_entry_sizes
end

#warn_invalid_dateObject

Returns the value of attribute warn_invalid_date.



38
39
40
# File 'lib/zip.rb', line 38

def warn_invalid_date
  @warn_invalid_date
end

#write_zip64_supportObject

Returns the value of attribute write_zip64_support.



38
39
40
# File 'lib/zip.rb', line 38

def write_zip64_support
  @write_zip64_support
end

Instance Method Details

#reset!Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/zip.rb', line 49

def reset!
  @_ran_once = false
  @unicode_names = false
  @on_exists_proc = false
  @continue_on_exists_proc = false
  @sort_entries = false
  @default_compression = ::Zlib::DEFAULT_COMPRESSION
  @write_zip64_support = false
  @warn_invalid_date = true
  @case_insensitive_match = false
  @validate_entry_sizes = true
end

#setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Zip)

    the object that the method was called on



62
63
64
65
# File 'lib/zip.rb', line 62

def setup
  yield self unless @_ran_once
  @_ran_once = true
end