|
IP*Works! ZIP V8 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ipworkszip.ZIPFile
The Zip file in the archive.
This type contains information about the Zip file that either exists in the archive or is being added to the archive.
Attributes: The attributes of the files to be compressed or decompressed. It will then be written to the archive during compression and to the file system during extraction.
If desired, you may change the value of Attributes before compressing or decompressing.
The property is a bitmask of flags, corresponding to the MS-DOS directory byte:
In the Java Edition , due to limitations of the JRE, the effect of this property is limited. When including files, only the Hidden and Readonly bits will be read from the file system, and during extraction only the Readonly attribute will be written.
Comment: Specifies a comment for the entry in the zip file. Before compression, set this field to include comments in this zip file. After an archive has been scanned, this field will contain any comments the zip file contains.
CompressedDate: The date and time of the entry, as stored within the archive.
FileCompressedDate contains the last modified date of the file, as stored within the archive. (It does not generally correspond to when the file was compressed.)
FileCompressedDate is returned in a platform-specific format. The Java Edition will return the number of milliseconds since January 1, 1970, 00:00:00. This value may be passed directly to the java.util.Date constructor to create a java.util.Date object representing this date.
The .NET Edition will return the number of ticks, or 100-nanosecond intervals, since January 1, 0001, 00:00:00. This value may be passed directly to the System.DateTime constructor to create a System.DateTime object representing this date.
Reading the value of this property will return a meaningful value only after the archive has
been successfully scanned or decompressed, and only if the values
of ArchiveFile
, Files
collection, and CompressedName
have not been changed since.
If a meaningful value is not available this property will return a value of 0.
NOTE: This may be set accordingly when the InputStream
field is set to a valid stream to
input the data for the current file. If not set, the default, 0, is used. Otherwise the
value is read from disk.
CompressedName:
The file name of the current file, as stored inside of the archive.
This may be the same as in DecompressedName
, but is not required to be.
All paths are stored in the archive in standard (UNIX) format. Pathnames specified in the host operating system's format will be immediately converted.
This field should generally be set with a relative path or with no path at all. The exact interpretation of the path is left to the decompression software; generally, pathnames will be interpreted as relative to a base directory, and these subdirectories will be created as needed. Absolute pathnames will not be interpreted correctly by the bean, and may or may not be interpreted correctly by other decompression software.
Paths should be specified in standard (UNIX) format. They may also be specified in the format native to the host operating system, in which case they will be immediately converted.
Example
ZipControl.ArchiveFile = "c:\\test.zip"
ZipControl.Files.Add(new ZIPFile())
ZipControl.Files[0].DecompressedName = "c:\\test\\ipworkszip\\temp\\test.txt"
ZipControl.Files[0].CompressedName = "readme.txt"
ZipControl.Compress()
CompressedSize: The size of the compressed data, as compressed within the archive. Headers, footers, etc., are not included in the size.
Reading the value of this property will return a meaningful value only after the
archive has been compressed, scanned, or decompressed, and only if the values
of ArchiveFile
, Files
have not been changed since.
If a meaningful value is not available this property will return a value of -1.
CRC:
The CRC
value for the specified file found in
the archive. This value is populated after compression
or decompression.
DecompressedName: The name of the file in the archive, as stored on the file system, outside the archive.
When compressing files, this field should be specified with a path, if necessary, to allow the file to be found by the bean. If the file cannot be found during compression, a trappable error will be generated, and the archive will not be correctly written.
When decompressing files, the field indicates where the file should be written. After the
archive is scanned, the values of CompressedName
and DecompressedName will be
set to the exact filenames found in the archive. The value of DecompressedName may then be changed if desired.
If DecompressedName is set to an empty string before extraction, the file
will not be written to disk at all. It will still be written to the Progress event
if WriteToProgressEvent
is set to true.
If DecompressedName is set to an empty string before compression, the file will be skipped, and not written to the archive.
A base path for decompression may be specified by setting the ExtractToPath
property.
If ExtractToPath
is set to a non-empty string, the files will be decompressed to the
directory specified in ExtractToPath
. If the value of DecompressedName
contains
a pathname it will be regarded as relative to ExtractToPath
.
Paths on the local file system should be specified in the format native to the host operating system. They may also be specified in standard (UNIX) format, in which case they will be immediately converted.
Example
ZipControl.ArchiveFile = "c:\\test.tar"
ZipControl.Scan()
ZipControl.ExtractToPath = "c:\\temp\\"
ZipControl.Files[1].DecompressedName = "test\\temp.out"
ZipControl.Extract(ZipControl.Files[1].CompressedName)
Incorrect Example ZipControl.ExtractToPath = "c:\\temp\\"
ZipControl.Files[1].DecompressedName = "c:\\temp\\test\\temp.out"
'The file would be extracted to c:\\temp\\c:\\temp\\test\\temp.out
DecompressedSize:
The size of the file, as decompressed outside the archive. If an archive is open
for read (i.e. has been scanned or decompressed), this information will be read from
the archive headers. If an archive is not open for read, the bean will retrieve
the information for the corresponding value of DecompressedName
from the local
file system.
A value of -1 will be returned in case of an I/O error.
EncryptionAlgorithm: The algorithm used to encrypt the specified file written to the archive.
Note that the file will only be encrypted if Password
is set. By default the
bean will use standard zip encryption if Password
is set, and will not
encrypt data otherwise.
The bean supports the use of AES , the Advanced Encryption Standard, as well as standard Zip encryption. The default encryption algorithm is the algorithm introduced in version 2.0 of the Zip specification, and is compatible with virtually all other zip utilities. However, this algorithm is considered weak and should not be used to protect sensitive data.
AES is a U.S. government standard cleared to protect even the most sensitive data. The file format used to create AES-encrypted files is designed to be compatible with WinZip 9.0 . AES-encrypted files created by the bean may or may not be compatible with other Zip utilities.
The bean supports the use of AES with key lengths of 128, 192, or 256 bits. Note that even with the weakest (128-bit) keys AES is much more secure than standard Zip encryption.
If you use strong or maximum AES encryption the bean will generate a unique salt value and cryptographic key for each file encrypted. If you use weak encryption the bean will use the same salt for each file in the archive. If you are encrypting a large number of files this will have a substantial effect on performance. Set the AESGenerateUniqueKeys configuration setting to configure the salt generation independent of the key length.
If using AES encryption it is important to choose a good Password
. For 128-bit keys
it is recommended that your password be 32 characters long, and for 256-bit keys,
64 characters.
Important: Note that AES encryption only encrypts the contents of encrypted files within the Zip archive; it does not prevent an attacker from reading the names of files in the archive, or from adding or deleting files to or from the archive. To prevent this consider first storing your files in an unencrypted zip file, and then storing this zip file in another, AES-encrypted zip file.
To set the EncryptionAlgorithm
or Password
fields for the entire archive, use the EncryptionAlgorithm
or Password
properties.
Property values:
InputStream:
When this field is set to a valid stream, the bean will read in the data
from the stream as the current file instead of reading from the file contained
in the DecompressedName
field.
Password: This field specifies the case-sensitive password used to encrypt or decrypt the current file. If set to an empty string, no password is used.
For archives that have multiple files with the same password, you may
use the Password
property instead of the Password
field of the Files
collection. You may also use PasswordRequired
field to
see if a file requires a password after an archive has been scanned.
In this release, streaming out of encrypted archives is not supported.
When compressing, WriteToProgressEvent
must be set to
false if Password is set.
Example (Compressing an Archive)
ZipControl.ArchiveFile = "c:\\test.zip"
ZipControl.RecurseSubdirectories = true
ZipControl.IncludeFiles("c:\\foo\\*")
ZipControl.Password = "nsoftware"
ZipControl.Compress()
PasswordRequired: This field describes whether or not the current file has been encrypted or not and requires a password to decompress. It is populated after the archive has been scanned.
Gzip
,
Gzip.ZIPFile
Field Summary | |
static int |
eaAESMaximum
|
static int |
eaAESStrong
|
static int |
eaAESWeak
|
static int |
eaDefault
|
Constructor Summary | |
ZIPFile()
|
|
ZIPFile(java.lang.String decompressedName)
|
|
ZIPFile(java.lang.String compressedName,
java.io.InputStream inputStream)
|
|
ZIPFile(java.lang.String compressedName,
java.lang.String decompressedName)
|
Method Summary | |
int |
getAttributes()
|
java.lang.String |
getComment()
|
long |
getCompressedDate()
|
java.lang.String |
getCompressedName()
|
long |
getCompressedSize()
|
long |
getCRC()
|
java.lang.String |
getDecompressedName()
|
long |
getDecompressedSize()
|
int |
getEncryptionAlgorithm()
|
java.io.InputStream |
getInputStream()
|
java.lang.String |
getPassword()
|
boolean |
getPasswordRequired()
|
void |
setAttributes(int value)
|
void |
setComment(java.lang.String value)
|
void |
setCompressedDate(long value)
|
void |
setCompressedName(java.lang.String value)
|
void |
setDecompressedName(java.lang.String value)
|
void |
setEncryptionAlgorithm(int value)
|
void |
setInputStream(java.io.InputStream value)
|
void |
setPassword(java.lang.String value)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int eaDefault
public static final int eaAESWeak
public static final int eaAESStrong
public static final int eaAESMaximum
Constructor Detail |
public ZIPFile()
public ZIPFile(java.lang.String decompressedName)
public ZIPFile(java.lang.String compressedName, java.lang.String decompressedName)
public ZIPFile(java.lang.String compressedName, java.io.InputStream inputStream)
Method Detail |
public int getAttributes()
public void setAttributes(int value)
public java.lang.String getComment()
public void setComment(java.lang.String value)
public long getCompressedDate()
public void setCompressedDate(long value)
public java.lang.String getCompressedName()
public void setCompressedName(java.lang.String value)
public long getCompressedSize()
public long getCRC()
public java.lang.String getDecompressedName()
public void setDecompressedName(java.lang.String value)
public long getDecompressedSize()
public int getEncryptionAlgorithm()
public void setEncryptionAlgorithm(int value)
public java.io.InputStream getInputStream()
public void setInputStream(java.io.InputStream value)
public java.lang.String getPassword()
public void setPassword(java.lang.String value)
public boolean getPasswordRequired()
|
IP*Works! ZIP V8 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |