class LibZip::Entry
One record of the central directory: what the archive stores about an entry, without reading the entry.
An Entry is an immutable snapshot taken when it was listed, so its metadata remains readable after the entry is removed and after the archive is closed. It isn’t a handle: pass the name to LibZip::File#read for the bytes.
entry = zip["docs/a.txt"] entry.name # => "docs/a.txt" entry.size # => 1234 entry.compression_method # => LibZip::Entry::DEFLATED
Each accessor except name, index and directory? returns nil when the archive didn’t store that field, which a zip written by another tool is free to skip.
Entries come from LibZip::File#entries, each, [], find_entry, get_entry, glob, remove and rename; there’s no public constructor.
Constants
- AES_128
-
Encryption method: AES-128 (Winzip AE-2).
- AES_192
-
Encryption method: AES-192 (Winzip AE-2).
- AES_256
-
Encryption method: AES-256 (Winzip AE-2).
- DEFLATED
-
Compression method: deflate.
- NONE
-
Encryption method: none. What
encryption_methodgives for a plain entry. - STORED
-
Compression method: stored, no compression.
- TRAD_PKWARE
-
Encryption method: traditional PKWARE (ZipCrypto). Readable, and not allowed for writing, since libzip documents it as broken.
Public Instance Methods
Source
# File doc/api.rb, line 407 def comment end
The entry comment, as a UTF-8 String, or nil when it has none. A comment that isn’t valid UTF-8 comes back as ASCII-8BIT. Set it with LibZip::File#set_comment.
Source
# File doc/api.rb, line 363 def compressed_size end
The size in bytes as stored, after compression, or nil when the archive didn’t store it.
Source
Source
# File doc/api.rb, line 372 def crc end
The CRC-32 of the uncompressed data as an Integer, or nil when the archive didn’t store it.
AES entries use AE-2, which keeps no CRC, so this can be 0 for them; their integrity check is the HMAC, verified when the entry is read to the end.
Source
# File doc/api.rb, line 401 def directory? end
Whether this entry is a directory.
True for a name ending in /, and for an entry with external attributes that agree: a UNIX mode with S_IFDIR, or the MS-DOS directory bit. That’s how a directory written by another tool is identified.
Source
# File doc/api.rb, line 393 def encrypted? end
Whether the entry’s contents are encrypted, which means encryption_method is anything but NONE. false when the archive didn’t store the method.
Source
# File doc/api.rb, line 388 def encryption_method end
libzip’s numeric encryption method: NONE, TRAD_PKWARE, AES_128, AES_192 or AES_256. nil when the archive didn’t store it.
Source
# File doc/api.rb, line 353 def index end
The entry’s position in the archive, counting from 0.
Source
# File doc/api.rb, line 415 def inspect end
<LibZip::Entry name=“docs/a.txt” size=1234>
Source
# File doc/api.rb, line 349 def name end
The entry name, as a UTF-8 String. Directory entries keep the trailing / they’re stored with.
Source
# File doc/api.rb, line 358 def size end
The uncompressed size in bytes, or nil when the archive didn’t store it.
Source
# File doc/api.rb, line 377 def time end
The modification time, as a Time, or nil when the archive didn’t store it.