Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Zip.ZipEntry Class Reference

This class represents an entry in a zip archive. This can be a file or a directory ZipFile and ZipInputStream will give you instances of this class as information about the members in an archive. ZipOutputStream uses an instance of this class when creating an entry in a Zip file.

Author of the original java version : Jochen Hoenicke. More...

Inheritance diagram for ICSharpCode.SharpZipLib.Zip.ZipEntry:
Collaboration diagram for ICSharpCode.SharpZipLib.Zip.ZipEntry:

Public Member Functions

 ZipEntry (string name)
 Creates a zip entry with the given name.
 ZipEntry (ZipEntry entry)
 Creates a deep copy of the given zip entry.
void ForceZip64 ()
 Force this entry to be recorded using Zip64 extensions.
bool IsZip64Forced ()
 Get a value indicating wether Zip64 extensions were forced.
bool IsCompressionMethodSupported ()
 Test entry to see if data can be extracted.
object Clone ()
 Creates a copy of this zip entry.
override string ToString ()
 Gets a string representation of this ZipEntry.

Static Public Member Functions

static bool IsCompressionMethodSupported (CompressionMethod method)
 Test a compression method to see if this library supports extracting data compressed with that method.
static string CleanName (string name)
 Cleans a name making it conform to Zip file conventions. Devices names ('c:\') and UNC share names ('\server\share') are removed and forward slashes ('\') are converted to back slashes ('/'). Names are made relative by trimming leading slashes which is compatible with the ZIP naming convention.

Package Functions

 ZipEntry (string name, int versionRequiredToExtract)
 Creates a zip entry with the given name and version required to extract.
 ZipEntry (string name, int versionRequiredToExtract, int madeByInfo, CompressionMethod method)
 Initializes an entry with the given name and made by information.
void ProcessExtraData (bool localHeader)
 Process extra data fields updating the entry based on the contents.

Properties

bool HasCrc [get]
 Get a value indicating wether the entry has a CRC value available.
bool IsCrypted [get, set]
 Get/Set flag indicating if entry is encrypted. A simple helper routine to aid interpretation of flags
bool IsUnicodeText [get, set]
 Get / set a flag indicating wether entry name and comment text are encoded in unicode UTF8.
byte CryptoCheckValue [get, set]
 Value used during password checking for PKZIP 2.0 / 'classic' encryption.
int Flags [get, set]
 Get/Set general purpose bit flag for entry.
long ZipFileIndex [get, set]
 Get/Set index of this entry in Zip file.
long Offset [get, set]
 Get/set offset for use in central header.
int ExternalFileAttributes [get, set]
 Get/Set external file attributes as an integer. The values of this are operating system dependant see HostSystem for details.
int VersionMadeBy [get]
 Get the version made by for this entry or zero if unknown. The value / 10 indicates the major version number, and the value mod 10 is the minor version number.
bool IsDOSEntry [get]
 Get a value indicating this entry is for a DOS/Windows system.
int HostSystem [get, set]
 Gets the compatability information for the external file attribute If the external file attributes are compatible with MS-DOS and can be read by PKZIP for DOS version 2.04g then this value will be zero. Otherwise the value will be non-zero and identify the host system on which the attributes are compatible.
int Version [get]
 Get minimum Zip feature version required to extract this entry.
bool CanDecompress [get]
 Get a value indicating whether this entry can be decompressed by the library.
bool LocalHeaderRequiresZip64 [get]
 Gets a value indicating if the entry requires Zip64 extensions to store the full entry values.
bool CentralHeaderRequiresZip64 [get]
 Get a value indicating wether the central directory entry requires Zip64 extensions to be stored.
long DosTime [get, set]
 Get/Set DosTime value.
DateTime DateTime [get, set]
 Gets/Sets the time of last modification of the entry.
string Name [get]
 Returns the entry name.
long Size [get, set]
 Gets/Sets the size of the uncompressed data.
long CompressedSize [get, set]
 Gets/Sets the size of the compressed data.
long Crc [get, set]
 Gets/Sets the crc of the uncompressed data.
CompressionMethod CompressionMethod [get, set]
 Gets/Sets the compression method. Only Deflated and Stored are supported.
CompressionMethod CompressionMethodForHeader [get]
 Gets the compression method for outputting to the local or central header. Returns same value as CompressionMethod except when AES encrypting, which places 99 in the method and places the real method in the extra data.
byte[] ExtraData [get, set]
 Gets/Sets the extra data.
int AESKeySize [get, set]
 For AES encrypted files returns or sets the number of bits of encryption (128, 192 or 256). When setting, only 0 (off), 128 or 256 is supported.
byte AESEncryptionStrength [get]
 AES Encryption strength for storage in extra data in entry header. 1 is 128 bit, 2 is 192 bit, 3 is 256 bit.
int AESSaltLen [get]
 Returns the length of the salt, in bytes.
int AESOverheadSize [get]
 Number of extra bytes required to hold the AES Header fields (Salt, Pwd verify, AuthCode)
string Comment [get, set]
 Gets/Sets the entry comment.
bool IsDirectory [get]
 Gets a value indicating if the entry is a directory. however.
bool IsFile [get]
 Get a value of true if the entry appears to be a file; false otherwise.

Private Types

enum  Known : byte {
  None = 0 , Size = 0x01 , CompressedSize = 0x02 , Crc = 0x04 ,
  Time = 0x08 , ExternalAttributes = 0x10
}

Private Member Functions

bool HasDosAttributes (int attributes)
 Test the external attributes for this ZipEntry to see if the external attributes are Dos based (including WINNT and variants) and match the values.
void ProcessAESExtraData (ZipExtraData extraData)

Private Attributes

Known known
int externalFileAttributes = -1
ushort versionMadeBy
string name
ulong size
ulong compressedSize
ushort versionToExtract
uint crc
uint dosTime
CompressionMethod method = CompressionMethod.Deflated
byte[] extra
string comment
int flags
long zipFileIndex = -1
long offset
bool forceZip64_
byte cryptoCheckValue_
int _aesVer
int _aesEncryptionStrength

Detailed Description

This class represents an entry in a zip archive. This can be a file or a directory ZipFile and ZipInputStream will give you instances of this class as information about the members in an archive. ZipOutputStream uses an instance of this class when creating an entry in a Zip file.

Author of the original java version : Jochen Hoenicke.

Member Enumeration Documentation

◆ Known

Enumerator
None 
Size 
CompressedSize 
Crc 
Time 
ExternalAttributes 

Constructor & Destructor Documentation

◆ ZipEntry() [1/4]

ICSharpCode.SharpZipLib.Zip.ZipEntry.ZipEntry ( string name)

Creates a zip entry with the given name.

Parameters
nameThe name for this entry. Can include directory components. The convention for names is 'unix' style paths with relative names only. There are with no device names and path elements are separated by '/' characters.
Exceptions
ArgumentNullExceptionThe name passed is null
Here is the caller graph for this function:

◆ ZipEntry() [2/4]

ICSharpCode.SharpZipLib.Zip.ZipEntry.ZipEntry ( string name,
int versionRequiredToExtract )
package

Creates a zip entry with the given name and version required to extract.

Parameters
nameThe name for this entry. Can include directory components. The convention for names is 'unix' style paths with no device names and path elements separated by '/' characters. This is not enforced see CleanName on how to ensure names are valid if this is desired.
versionRequiredToExtractThe minimum 'feature version' required this entry
Exceptions
ArgumentNullExceptionThe name passed is null

◆ ZipEntry() [3/4]

ICSharpCode.SharpZipLib.Zip.ZipEntry.ZipEntry ( string name,
int versionRequiredToExtract,
int madeByInfo,
CompressionMethod method )
package

Initializes an entry with the given name and made by information.

Parameters
nameName for this entry
madeByInfoVersion and HostSystem Information
versionRequiredToExtractMinimum required zip feature version required to extract this entry
methodCompression method for this entry.
Exceptions
ArgumentNullExceptionThe name passed is null
ArgumentOutOfRangeExceptionversionRequiredToExtract should be 0 (auto-calculate) or > 10

This constructor is used by the ZipFile class when reading from the central header It is not generally useful, use the constructor specifying the name only.

◆ ZipEntry() [4/4]

ICSharpCode.SharpZipLib.Zip.ZipEntry.ZipEntry ( ZipEntry entry)

Creates a deep copy of the given zip entry.

Parameters
entryThe entry to copy.
Here is the call graph for this function:

Member Function Documentation

◆ CleanName()

string ICSharpCode.SharpZipLib.Zip.ZipEntry.CleanName ( string name)
static

Cleans a name making it conform to Zip file conventions. Devices names ('c:\') and UNC share names ('\server\share') are removed and forward slashes ('\') are converted to back slashes ('/'). Names are made relative by trimming leading slashes which is compatible with the ZIP naming convention.

Parameters
nameThe name to clean
Returns
The 'cleaned' name.

The

See also
ZipNameTransform

Zip name transform

class is more flexible.

◆ Clone()

object ICSharpCode.SharpZipLib.Zip.ZipEntry.Clone ( )

Creates a copy of this zip entry.

Returns
An Object that is a copy of the current instance.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ForceZip64()

void ICSharpCode.SharpZipLib.Zip.ZipEntry.ForceZip64 ( )

Force this entry to be recorded using Zip64 extensions.

Here is the caller graph for this function:

◆ HasDosAttributes()

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.HasDosAttributes ( int attributes)
private

Test the external attributes for this ZipEntry to see if the external attributes are Dos based (including WINNT and variants) and match the values.

Parameters
attributesThe attributes to test.
Returns
Returns true if the external attributes are known to be DOS/Windows based and have the same attributes set as the value passed.

◆ IsCompressionMethodSupported() [1/2]

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsCompressionMethodSupported ( )

Test entry to see if data can be extracted.

Returns
Returns true if data can be extracted for this entry; false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsCompressionMethodSupported() [2/2]

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsCompressionMethodSupported ( CompressionMethod method)
static

Test a compression method to see if this library supports extracting data compressed with that method.

Parameters
methodThe compression method to test.
Returns
Returns true if the compression method is supported; false otherwise

◆ IsZip64Forced()

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsZip64Forced ( )

Get a value indicating wether Zip64 extensions were forced.

Returns
A bool value of true if Zip64 extensions have been forced on; false if not.
Here is the caller graph for this function:

◆ ProcessAESExtraData()

void ICSharpCode.SharpZipLib.Zip.ZipEntry.ProcessAESExtraData ( ZipExtraData extraData)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessExtraData()

void ICSharpCode.SharpZipLib.Zip.ZipEntry.ProcessExtraData ( bool localHeader)
package

Process extra data fields updating the entry based on the contents.

Parameters
localHeaderTrue if the extra data fields should be handled for a local header, rather than for a central header.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

override string ICSharpCode.SharpZipLib.Zip.ZipEntry.ToString ( )

Gets a string representation of this ZipEntry.

Returns
A readable textual representation of this ZipEntry

Member Data Documentation

◆ _aesEncryptionStrength

int ICSharpCode.SharpZipLib.Zip.ZipEntry._aesEncryptionStrength
private

◆ _aesVer

int ICSharpCode.SharpZipLib.Zip.ZipEntry._aesVer
private

◆ comment

string ICSharpCode.SharpZipLib.Zip.ZipEntry.comment
private

◆ compressedSize

ulong ICSharpCode.SharpZipLib.Zip.ZipEntry.compressedSize
private

◆ crc

uint ICSharpCode.SharpZipLib.Zip.ZipEntry.crc
private

◆ cryptoCheckValue_

byte ICSharpCode.SharpZipLib.Zip.ZipEntry.cryptoCheckValue_
private

◆ dosTime

uint ICSharpCode.SharpZipLib.Zip.ZipEntry.dosTime
private

◆ externalFileAttributes

int ICSharpCode.SharpZipLib.Zip.ZipEntry.externalFileAttributes = -1
private

◆ extra

byte [] ICSharpCode.SharpZipLib.Zip.ZipEntry.extra
private

◆ flags

int ICSharpCode.SharpZipLib.Zip.ZipEntry.flags
private

◆ forceZip64_

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.forceZip64_
private

◆ known

Known ICSharpCode.SharpZipLib.Zip.ZipEntry.known
private

◆ method

CompressionMethod ICSharpCode.SharpZipLib.Zip.ZipEntry.method = CompressionMethod.Deflated
private

◆ name

string ICSharpCode.SharpZipLib.Zip.ZipEntry.name
private

◆ offset

long ICSharpCode.SharpZipLib.Zip.ZipEntry.offset
private

◆ size

ulong ICSharpCode.SharpZipLib.Zip.ZipEntry.size
private

◆ versionMadeBy

ushort ICSharpCode.SharpZipLib.Zip.ZipEntry.versionMadeBy
private

◆ versionToExtract

ushort ICSharpCode.SharpZipLib.Zip.ZipEntry.versionToExtract
private

◆ zipFileIndex

long ICSharpCode.SharpZipLib.Zip.ZipEntry.zipFileIndex = -1
private

Property Documentation

◆ AESEncryptionStrength

byte ICSharpCode.SharpZipLib.Zip.ZipEntry.AESEncryptionStrength
getpackage

AES Encryption strength for storage in extra data in entry header. 1 is 128 bit, 2 is 192 bit, 3 is 256 bit.

◆ AESKeySize

int ICSharpCode.SharpZipLib.Zip.ZipEntry.AESKeySize
getset

For AES encrypted files returns or sets the number of bits of encryption (128, 192 or 256). When setting, only 0 (off), 128 or 256 is supported.

◆ AESOverheadSize

int ICSharpCode.SharpZipLib.Zip.ZipEntry.AESOverheadSize
getpackage

Number of extra bytes required to hold the AES Header fields (Salt, Pwd verify, AuthCode)

◆ AESSaltLen

int ICSharpCode.SharpZipLib.Zip.ZipEntry.AESSaltLen
getpackage

Returns the length of the salt, in bytes.

◆ CanDecompress

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.CanDecompress
get

Get a value indicating whether this entry can be decompressed by the library.

This is based on the Version and wether the compression method is supported.

◆ CentralHeaderRequiresZip64

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.CentralHeaderRequiresZip64
get

Get a value indicating wether the central directory entry requires Zip64 extensions to be stored.

◆ Comment

string ICSharpCode.SharpZipLib.Zip.ZipEntry.Comment
getset

Gets/Sets the entry comment.

Exceptions
System.ArgumentOutOfRangeExceptionIf comment is longer than 0xffff.
Returns
The comment or null if not set.

A comment is only available for entries when read via the ZipFile class. The ZipInputStream class doesnt have the comment data available.

◆ CompressedSize

long ICSharpCode.SharpZipLib.Zip.ZipEntry.CompressedSize
getset

Gets/Sets the size of the compressed data.

Returns
The compressed entry size or -1 if unknown.

◆ CompressionMethod

CompressionMethod ICSharpCode.SharpZipLib.Zip.ZipEntry.CompressionMethod
getset

Gets/Sets the compression method. Only Deflated and Stored are supported.

Returns
The compression method for this entry

ICSharpCode.SharpZipLib.Zip.CompressionMethod.Deflated ICSharpCode.SharpZipLib.Zip.CompressionMethod.Stored

◆ CompressionMethodForHeader

CompressionMethod ICSharpCode.SharpZipLib.Zip.ZipEntry.CompressionMethodForHeader
getpackage

Gets the compression method for outputting to the local or central header. Returns same value as CompressionMethod except when AES encrypting, which places 99 in the method and places the real method in the extra data.

◆ Crc

long ICSharpCode.SharpZipLib.Zip.ZipEntry.Crc
getset

Gets/Sets the crc of the uncompressed data.

Exceptions
System.ArgumentOutOfRangeExceptionCrc is not in the range 0..0xffffffffL
Returns
The crc value or -1 if unknown.

◆ CryptoCheckValue

byte ICSharpCode.SharpZipLib.Zip.ZipEntry.CryptoCheckValue
getsetpackage

Value used during password checking for PKZIP 2.0 / 'classic' encryption.

◆ DateTime

DateTime ICSharpCode.SharpZipLib.Zip.ZipEntry.DateTime
getset

Gets/Sets the time of last modification of the entry.

The DosTime property is updated to match this as far as possible.

◆ DosTime

long ICSharpCode.SharpZipLib.Zip.ZipEntry.DosTime
getset

Get/Set DosTime value.

The MS-DOS date format can only represent dates between 1/1/1980 and 12/31/2107.

◆ ExternalFileAttributes

int ICSharpCode.SharpZipLib.Zip.ZipEntry.ExternalFileAttributes
getset

Get/Set external file attributes as an integer. The values of this are operating system dependant see HostSystem for details.

◆ ExtraData

byte [] ICSharpCode.SharpZipLib.Zip.ZipEntry.ExtraData
getset

Gets/Sets the extra data.

Exceptions
System.ArgumentOutOfRangeExceptionExtra data is longer than 64KB (0xffff) bytes.
Returns
Extra data or null if not set.

◆ Flags

int ICSharpCode.SharpZipLib.Zip.ZipEntry.Flags
getset

Get/Set general purpose bit flag for entry.

General purpose bit flag

Bit 0: If set, indicates the file is encrypted
Bit 1-2 Only used for compression type 6 Imploding, and 8, 9 deflating
Imploding:
Bit 1 if set indicates an 8K sliding dictionary was used. If clear a 4k dictionary was used
Bit 2 if set indicates 3 Shannon-Fanno trees were used to encode the sliding dictionary, 2 otherwise

Deflating:
Bit 2 Bit 1
0 0 Normal compression was used
0 1 Maximum compression was used
1 0 Fast compression was used
1 1 Super fast compression was used

Bit 3: If set, the fields crc-32, compressed size and uncompressed size are were not able to be written during zip file creation The correct values are held in a data descriptor immediately following the compressed data.
Bit 4: Reserved for use by PKZIP for enhanced deflating
Bit 5: If set indicates the file contains compressed patch data
Bit 6: If set indicates strong encryption was used.
Bit 7-10: Unused or reserved
Bit 11: If set the name and comments for this entry are in unicode.
Bit 12-15: Unused or reserved

See also
IsUnicodeText
See also
IsCrypted

◆ HasCrc

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.HasCrc
get

Get a value indicating wether the entry has a CRC value available.

◆ HostSystem

int ICSharpCode.SharpZipLib.Zip.ZipEntry.HostSystem
getset

Gets the compatability information for the external file attribute If the external file attributes are compatible with MS-DOS and can be read by PKZIP for DOS version 2.04g then this value will be zero. Otherwise the value will be non-zero and identify the host system on which the attributes are compatible.

The values for this as defined in the Zip File format and by others are shown below. The values are somewhat misleading in some cases as they are not all used as shown. You should consult the relevant documentation to obtain up to date and correct information. The modified appnote by the infozip group is particularly helpful as it documents a lot of peculiarities. The document is however a little dated.

- MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) 1 - Amiga 2 - OpenVMS 3 - Unix 4 - VM/CMS 5 - Atari ST 6 - OS/2 HPFS 7 - Macintosh 8 - Z-System 9 - CP/M 10 - Windows NTFS 11 - MVS (OS/390 - Z/OS) 12 - VSE 13 - Acorn Risc 14 - VFAT 15 - Alternate MVS 16 - BeOS 17 - Tandem 18 - OS/400 19 - OS/X (Darwin) 99 - WinZip AES remainder - unused

◆ IsCrypted

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsCrypted
getset

Get/Set flag indicating if entry is encrypted. A simple helper routine to aid interpretation of flags

This is an assistant that interprets the flags property.

◆ IsDirectory

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsDirectory
get

Gets a value indicating if the entry is a directory. however.

A directory is determined by an entry name with a trailing slash '/'. The external file attributes can also indicate an entry is for a directory. Currently only dos/windows attributes are tested in this manner. The trailing slash convention should always be followed.

◆ IsDOSEntry

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsDOSEntry
get

Get a value indicating this entry is for a DOS/Windows system.

◆ IsFile

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsFile
get

Get a value of true if the entry appears to be a file; false otherwise.

This only takes account of DOS/Windows attributes. Other operating systems are ignored. For linux and others the result may be incorrect.

◆ IsUnicodeText

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.IsUnicodeText
getset

Get / set a flag indicating wether entry name and comment text are encoded in unicode UTF8.

This is an assistant that interprets the flags property.

◆ LocalHeaderRequiresZip64

bool ICSharpCode.SharpZipLib.Zip.ZipEntry.LocalHeaderRequiresZip64
get

Gets a value indicating if the entry requires Zip64 extensions to store the full entry values.

A bool value of true if a local header requires Zip64 extensions; false if not.

◆ Name

string ICSharpCode.SharpZipLib.Zip.ZipEntry.Name
get

Returns the entry name.

The unix naming convention is followed. Path components in the entry should always separated by forward slashes ('/'). Dos device names like C: should also be removed. See the ZipNameTransform class, or CleanName(string) /remarks>

◆ Offset

long ICSharpCode.SharpZipLib.Zip.ZipEntry.Offset
getset

Get/set offset for use in central header.

◆ Size

long ICSharpCode.SharpZipLib.Zip.ZipEntry.Size
getset

Gets/Sets the size of the uncompressed data.

Returns
The size or -1 if unknown.

Setting the size before adding an entry to an archive can help avoid compatability problems with some archivers which dont understand Zip64 extensions.

◆ Version

int ICSharpCode.SharpZipLib.Zip.ZipEntry.Version
get

Get minimum Zip feature version required to extract this entry.


Minimum features are defined as:
1.0 - Default value
1.1 - File is a volume label
2.0 - File is a folder/directory
2.0 - File is compressed using Deflate compression
2.0 - File is encrypted using traditional encryption
2.1 - File is compressed using Deflate64
2.5 - File is compressed using PKWARE DCL Implode
2.7 - File is a patch data set
4.5 - File uses Zip64 format extensions
4.6 - File is compressed using BZIP2 compression
5.0 - File is encrypted using DES
5.0 - File is encrypted using 3DES
5.0 - File is encrypted using original RC2 encryption
5.0 - File is encrypted using RC4 encryption
5.1 - File is encrypted using AES encryption
5.1 - File is encrypted using corrected RC2 encryption
5.1 - File is encrypted using corrected RC2-64 encryption
6.1 - File is encrypted using non-OAEP key wrapping
6.2 - Central directory encryption (not confirmed yet)
6.3 - File is compressed using LZMA
6.3 - File is compressed using PPMD+
6.3 - File is encrypted using Blowfish
6.3 - File is encrypted using Twofish

See also
CanDecompress

◆ VersionMadeBy

int ICSharpCode.SharpZipLib.Zip.ZipEntry.VersionMadeBy
get

Get the version made by for this entry or zero if unknown. The value / 10 indicates the major version number, and the value mod 10 is the minor version number.

◆ ZipFileIndex

long ICSharpCode.SharpZipLib.Zip.ZipEntry.ZipFileIndex
getset

Get/Set index of this entry in Zip file.

This is only valid when the entry is part of a ZipFile


The documentation for this class was generated from the following file: