Zip C Library Reference
Zip
Zip compression C library.
Create/Dispose
HCkZip CkZip_Create(void);
Creates an instance of the CkZip object and returns a handle (i.e. a "void *" pointer). The handle is passed in the 1st argument for the functions listed on this page.
void CkZip_Dispose(HCkZip handle);
Objects created by calling CkZip_Create must be freed by calling this method. A memory leak occurs if a handle is not disposed by calling this function.
C "Properties"
void CkZip_getAppendFromDir(HCkZip cHandle, HCkString retval); void CkZip_putAppendFromDir(HCkZip cHandle, const char *newVal);
When files are added to a Zip archive, they are appended from this directory. For example, if you wish to add all the files under c:/abc/123/myAppDir, you might set this property equal to "c:/abc/123", and then pass "myAppDir/*" to AppendFiles.
void CkZip_getAutoRun(HCkZip cHandle, HCkString retval); void CkZip_putAutoRun(HCkZip cHandle, const char *newVal);
Optional when creating self-extracting EXEs. This is the name of an executable contained within the to-be-created EXE that will automatically be run after extraction. (This is typically something like "setup.exe")
void CkZip_getAutoRunParams(HCkZip cHandle, HCkString retval); void CkZip_putAutoRunParams(HCkZip cHandle, const char *newVal);
Command line parameters that get passed to the AutoRun executable.
BOOL CkZip_getAutoTemp(HCkZip cHandle); void CkZip_putAutoTemp(HCkZip cHandle, BOOL newVal);
This option applies to creating self-extracting EXEs. If true, the to-be-created EXE will automatically select and create a temporary directory for unzipping. This property is often used in conjunction with the AutoRun property to create a self-extracting EXE that automatically unzips to a temp directory and runs a setup.exe without interaction with the user.
Note: To create a self-extracting EXE with no user-interaction, set the following properties to these values:
ExeSilentProgress = false
ExeNoInterface = true
ExeFinishNotifier = false
The default AutoTemp value is false.
BOOL CkZip_getCaseSensitive(HCkZip cHandle); void CkZip_putCaseSensitive(HCkZip cHandle, BOOL newVal);
If true then all methods that get or search for zip entries by name will use case-sensitive filename matching. If false then filename matching will be case insensitive. Methods affected by this property include GetEntryByName, UnzipMatching, FirstMatchingEntry, etc.
The default value is true.
BOOL CkZip_getClearArchiveAttribute(HCkZip cHandle); void CkZip_putClearArchiveAttribute(HCkZip cHandle, BOOL newVal);
Set this to true to clear the FILE_ATTRIBUTE_ARCHIVE file attribute of each file during a zipping operation.
The default value is false.
BOOL CkZip_getClearReadOnlyAttr(HCkZip cHandle); void CkZip_putClearReadOnlyAttr(HCkZip cHandle, BOOL newVal);
If true, the read-only attribute is automatically cleared when unzipping. The default value of this property is false, which leaves the read-only attribute unchanged when unzipping.
void CkZip_getComment(HCkZip cHandle, HCkString retval); void CkZip_putComment(HCkZip cHandle, const char *newVal);
The global Zip file comment.
void CkZip_getDecryptPassword(HCkZip cHandle, HCkString retval); void CkZip_putDecryptPassword(HCkZip cHandle, const char *newVal);
When opening a password-protected or AES encrypted Zip, this is the password to be used for decryption. Encrypted Zips may be opened without setting a password, but the contents cannot be unzipped without setting this password.
Note:The SetPassword method has the effect of setting both this property as well as the EncryptPassword property. The SetPassword method should no longer be used. It has been replaced by the DecryptPassword and EncryptPassword properties to make it possible to open an encrypted zip and re-write it with a new password.
BOOL CkZip_getDiscardPaths(HCkZip cHandle); void CkZip_putDiscardPaths(HCkZip cHandle, BOOL newVal);
If true, discards all file path information when zipping. The default value is false.
long CkZip_getEncryptKeyLength(HCkZip cHandle); void CkZip_putEncryptKeyLength(HCkZip cHandle, long newVal);
The encryption key length if AES, Blowfish, Twofish, or WinZip-compatible AES encryption is used. This value must be 128, 192, or 256. The default value is 128.
void CkZip_getEncryptPassword(HCkZip cHandle, HCkString retval); void CkZip_putEncryptPassword(HCkZip cHandle, const char *newVal);
The password used when writing a password-protected or strong-encrytped Zip.
Note:The SetPassword method has the effect of setting both this property as well as the DecryptPassword property. The SetPassword method should no longer be used. It has been replaced by the DecryptPassword and EncryptPassword properties to make it possible to open an encrypted zip and re-write it with a new password.
long CkZip_getEncryption(HCkZip cHandle); void CkZip_putEncryption(HCkZip cHandle, long newVal);
The symmetric encryption algorithm. Valid values are: 0 = none, 1 = blowfish, 2 = twofish, 3 = rijndael (AES), 4 = WinZip compatible AES. When a Zip is encrypted, the directory will still be readable by programs such as WinZip, but the contents, if unzipped, will be encrypted. For modes 1,2, and 3, only applications using Chilkat Zip can decrypt and unzip Zip files created by Chilkat Zip. However, setting this property = 4 produces a WinZip compatible AES encrypted .zip file.
Note:Chilkat implemented strong-encryption prior to WinZip. When modes 1, 2, and 3 were originally implemented, WinZip AES encryption did not yet exist. When WinZip introduced AES encryption, Chilkat added mode 4 to provide the ability to create compatible AES-encrypted zips.
Important:The Encryption and PasswordProtect properties are mutually exclusive. PasswordProtect corresponds to the older Zip 2.0 encryption, commonly referred to as a "password-protected" zip. If the PasswordProtect is set to true, the Encryption property should be set to 0. If the Encryption property is set to a non-zero value, then PasswordProtect should be set to false. A zip cannot be both password-protected and strong-encrypted.
void CkZip_getExeDefaultDir(HCkZip cHandle, HCkString retval); void CkZip_putExeDefaultDir(HCkZip cHandle, const char *newVal);
Specifies the default unzip directory path to appear in the user-interface dialog box when the self-extracting EXE is run.
BOOL CkZip_getExeFinishNotifier(HCkZip cHandle); void CkZip_putExeFinishNotifier(HCkZip cHandle, BOOL newVal);
If set to true, a "Finished" dialog box is displayed when the self-extracting EXE is finished extracting. The caption, title, and button text of the finish notifier dialog may be customized by calling SetExeConfigParam. The default value is false.
void CkZip_getExeIconFile(HCkZip cHandle, HCkString retval); void CkZip_putExeIconFile(HCkZip cHandle, const char *newVal);
Applies to creating self-extracting EXEs. This property can be set to a pre-existing icon filename (.ico) that will be embedded within the to-be-created EXE and set as its default icon.
BOOL CkZip_getExeNoInterface(HCkZip cHandle); void CkZip_putExeNoInterface(HCkZip cHandle, BOOL newVal);
Applies to creating self-extracting EXEs. When set to true, the to-be-created EXE will run without a user-interface. The default value is false.
Note: The ExeSilentProgress property needs to be set to true for the extract to be truly silent.
Important: If the AutoTemp property = true and there is no AutoRun EXE, and there is no ExeUnzipDir set, then the self-extracting EXE will always display a dialog to get the unzip directory. The reason is that it makes no sense to silently unzip to an auto-selected (and unknown) temp directory without anything happening afterwards.
Important: If the self-extracting EXE is encrypted, a password dialog will be displayed. The password dialog may be suppressed if the password is provided on the command line via the -pwd command-line option.
BOOL CkZip_getExeSilentProgress(HCkZip cHandle); void CkZip_putExeSilentProgress(HCkZip cHandle, BOOL newVal);
Determines whether a progress dialog is displayed when the self-extracting EXE is run. If ExeNoInterface = false (i.e. there is a main dialog with the ability to select the unzip directory), then the progress dialog is (by default) shown as a progress bar within the main dialog -- and this property has no effect. If ExeNoInterface = true, then a progress-only dialog is displayed if ExeSilentProgress = false. The default value of ExeSilentProgress is true.
void CkZip_getExeSourceUrl(HCkZip cHandle, HCkString retval); void CkZip_putExeSourceUrl(HCkZip cHandle, const char *newVal);
This property allows you to create a self-extracting EXE where the data to be extracted is not actually contained within the EXE. Instead, when the self-extracting EXE is run, your zip is downloaded from a URL and unzipped. The self-extracting EXE will automatically use the proxy specified by Internet Explorer if one is defined.
In practice, you would prepare your .zip and place it on your web server at a publicly accessible URL. You may then create and distribute self-extracting EXEs that have this URL embedded. Your zip on the web server may be updated at will, and your already-distributed self-extracting EXEs will always download and unzip the latest files.
void CkZip_getExeTitle(HCkZip cHandle, HCkString retval); void CkZip_putExeTitle(HCkZip cHandle, const char *newVal);
Applies to creating self-extracting EXEs. Sets the title of the main user-interface dialog that appears when the self-extracting EXE runs.
void CkZip_getExeUnzipCaption(HCkZip cHandle, HCkString retval); void CkZip_putExeUnzipCaption(HCkZip cHandle, const char *newVal);
Applies to creating self-extracting EXEs. Sets the unzipping caption of the main user-interface dialog that appears when the self-extracting EXE runs.
void CkZip_getExeUnzipDir(HCkZip cHandle, HCkString retval); void CkZip_putExeUnzipDir(HCkZip cHandle, const char *newVal);
Applies to creating self-extracting EXEs. Stores a pre-defined unzip directory within the self-extracting EXE so that it automatically unzips to this directory without user-intervention.
Environment variables may be included if surrounded by percent characters. For example: %TEMP%. Environment variables are expanded (i.e. resolved) when the self-extracting EXE runs.
Note: To create a self-extracting EXE with no user-interaction, set the following properties to these values:
ExeSilentProgress = false
ExeNoInterface = true
ExeFinishNotifier = false
BOOL CkZip_getExeWaitForSetup(HCkZip cHandle); void CkZip_putExeWaitForSetup(HCkZip cHandle, BOOL newVal);
If true, the self-extracting EXE will wait for the AutoRun EXE to complete before it exits. If false, the self-extracting EXE dialog (or process if running silently with no user-interface), is allowed to exit prior to the completion of the AutoRun EXE. The default value is true.
void CkZip_getExeXmlConfig(HCkZip cHandle, HCkString retval); void CkZip_putExeXmlConfig(HCkZip cHandle, const char *newVal);
Allows for an XML config document to be used to specify all possible options for self-extracting EXEs. This property is a string containing the XML config document.
The XML should have this format:
<SfxConfig>
<ErrPwdTitle>Title for incorrect password dialog</ErrPwdTitle>
<ErrPwdCaption>Caption for incorrect password dialog</ErrPwdCaption>
<FinOkBtn>Text on finish notifier button</FinOkBtn>
<PwdOkBtn>Text on password challenge dialog's "OK" button.</PwdOkBtn>
<PwdCancelBtn>Text on password challenge dialog's Cancel button.</PwdCancelBtn>
<ErrInvalidPassword>Incorrect password error message.</ErrInvalidPassword>
<MainUnzipBtn>Text on main dialog's unzip button</MainUnzipBtn>
<MainCloseBtn>Text on main dialog's quit/exit button</MainCloseBtn>
<MainBrowseBtn>Text on main dialog's browse-for-directory button.</MainBrowseBtn>
<MainUnzipLabel>Caption displayed in main dialog.</MainUnzipLabel>
<AutoTemp>"1|0"</AutoTemp>
<ShowFin>"1|0" Maps to ExeFinishNotifier property.</ShowFin>
<ShowMain>"1|0" Maps to ExeNoInterface property.</ShowMain>
<ShowProgress>"1|0" Maps to ExeSilentProgress property.</ShowProgress>
<WaitForSetup>"1|0" Maps to ExeWaitForSetup property.</WaitForSetup>
<Encryption>"1|0" 1=Yes, 0=No</Encryption>
<KeyLength>128|192|256</KeyLength>
<SetupExe>EXE to run after extracting. (Maps to AutoRun property)</SetupExe>
<UnzipDir>Pre-defined unzip directory. (Maps to ExeUnzipDir property)>
<DefaultDir>Default unzip directory to appear in the main dialog.
(Maps to ExeDefaultDir property)</DefaultDir>
<IconFile>Icon file to be used (Maps to ExeIconFile property)</IconFile>
<Url>Maps to ExeSourceUrl property.</Url>
<MainTitle>Maps to ExeTitle property.</MainTitle>
<MainCaption>Maps to ExeUnzipCaption property.</MainCaption>
<FinTitle>Title for the finish notifier dialog.</FinTitle>
<FinCaption>Caption for the finish notifier dialog.</FinTitle>
<ProgressTitle>Title for the progress dialog.</ProgressTitle>
<ProgressCaption>Caption for the progress dialog.</ProgressCaption>
<PwTitle>Title for the password challenge dialog.</PwTitle>
<PwCaption>Caption for the password challenge dialog.</PwCaption>
</SfxConfig>
int CkZip_getFileCount(HCkZip cHandle);
The number of files (excluding directories) contained within the Zip.
void CkZip_getFileName(HCkZip cHandle, HCkString retval); void CkZip_putFileName(HCkZip cHandle, const char *newVal);
The name of the Zip file. This file is created or overwritten when the Zip is saved.
BOOL CkZip_getHasZipFormatErrors(HCkZip cHandle);
true if the opened zip contained file format errors (that were not severe enough to prevent the zip from being opened and parsed).
BOOL CkZip_getIgnoreAccessDenied(HCkZip cHandle); void CkZip_putIgnoreAccessDenied(HCkZip cHandle, BOOL newVal);
If true, then files that cannot be read due to "access denied" (i.e. a file permission error) will be ignored and the call to WriteZip, WriteZipAndClose, WriteExe, etc. will return a success status. If false, then the "access denied" filesystem errors are not ignored and any occurance will cause the zip writing to fail. The default value is true.
void CkZip_getLastErrorHtml(HCkZip cHandle, HCkString retval);
Error information in HTML format for the last method called.
void CkZip_getLastErrorText(HCkZip cHandle, HCkString retval);
Error information in plain-text format for the last method called.
void CkZip_getLastErrorXml(HCkZip cHandle, HCkString retval);
Error information in XML format for the last method called.
long CkZip_getNumEntries(HCkZip cHandle);
The number of entries in the Zip, including both files and directories.
long CkZip_getOemCodePage(HCkZip cHandle); void CkZip_putOemCodePage(HCkZip cHandle, long newVal);
Sets the OEM code page to be used for Unicode filenames. This property defaults to the OEM code page of the computer.
BOOL CkZip_getOverwriteExisting(HCkZip cHandle); void CkZip_putOverwriteExisting(HCkZip cHandle, BOOL newVal);
Determines whether existing files are overwritten during unzipping. The default is true, which means that already-existing files will be overwritten. Set this property = false to prevent existing files from being overwritten when unzipping.
BOOL CkZip_getPasswordProtect(HCkZip cHandle); void CkZip_putPasswordProtect(HCkZip cHandle, BOOL newVal);
true if the Zip should be password-protected using older Zip 2.0 encryption, commonly referred to as "password-protection".
void CkZip_getPathPrefix(HCkZip cHandle, HCkString retval); void CkZip_putPathPrefix(HCkZip cHandle, const char *newVal);
A prefix that is added to each filename when zipping. One might set the PathPrefix to "subdir/" so that files are unzipped to a specified subdirectory when unzipping.
void CkZip_getProxy(HCkZip cHandle, HCkString retval); void CkZip_putProxy(HCkZip cHandle, const char *newVal);
(Optional) The name of a proxy to be used with the OpenFromWeb method. Only necessary if your computer uses a proxy to access the Internet. The proxy string should be formatted as "hostname:port", such as "www.chilkatsoft.com:100".
void CkZip_getTempDir(HCkZip cHandle, HCkString retval); void CkZip_putTempDir(HCkZip cHandle, const char *newVal);
The temporary directory to use when unzipping files. When running in ASP or ASP.NET, the default value of TempDir is set to the directory where the .zip is being written. Set this property to override the default.
BOOL CkZip_getTextFlag(HCkZip cHandle); void CkZip_putTextFlag(HCkZip cHandle, BOOL newVal);
If set to true, the component will set the "text flag" for each file having these filename extensions: .txt, .xml, .htm, and .html. It will also preserve the "text flag" for existing zips that are opened and rewritten. By default, this property is set to false.
It is generally not necessary to set the text flag for a zip entry.
BOOL CkZip_getUtf8(HCkZip cHandle); void CkZip_putUtf8(HCkZip cHandle, BOOL newVal);
When set to true, all "const char *" arguments are expected to be utf-8 strings. If set to false, the "const char *" arguments are expected to be ANSI strings.
BOOL CkZip_getVerboseLogging(HCkZip cHandle); void CkZip_putVerboseLogging(HCkZip cHandle, BOOL newVal);
If set to true, includes extra verbose logging in LastErrorText, LastErrorXml, and LastErrorHtml. The default value is false.
void CkZip_getVersion(HCkZip cHandle, HCkString retval);
The version of the component, such as "v9.0.1"
C "Methods"
BOOL CkZip_AddEmbedded(HCkZip cHandle, const char *exeFilename, const char *resourceName, const char *zipFilename);
Embeds a Zip file into an EXE as a custom resource. This resource can be opened by the EXE containing it at runtime by using the OpenMyEmbedded method. Returns TRUE for success, FALSE for failure.
void CkZip_AddNoCompressExtension(HCkZip cHandle, const char *fileExtension);
Attempting to compress already-compressed data is usually a waste of CPU cycles with little or no benefit. In fact, it is possible that attempting to compress already-compressed data results in a slightly increased size. The Zip file format allows for files to be "stored" rather than compressed. This allows the file data to be streamed directly into a .zip without compression.
An instance of the Zip object has an internal list of "no compress" extensions. A filename with a "no compress" extension is "stored" rather than compressed. Additional "no compress" extensions may be added by calling this method (once per file extension). You should pass the file extension, such as ".xyz" in fileExtension.
"no compress" extensions may be removed by calling RemoveNoCompressExtension.
The default "no compress" extensions are: .zip, .gif, .jpg, .gz, .rar, .jar, .tgz, .bz2, .z, .rpm, .msi, .png
HCkZipEntry CkZip_AppendBase64(HCkZip cHandle, const char *fileName, const char *data);
Creates a new Zip entry and initializes it with already-compressed data that is Base64 encoded. (The ZipEntry.CopyBase64 method can be used to retrieve the compressed data in Base64 format.) Returns a null reference on failure
HCkZipEntry CkZip_AppendCompressed(HCkZip cHandle, const char *fileName, HCkByteData data);
Append memory data that is already Zip-compressed to the Zip object. The ZipEntry object containing the compressed data is returned. Note: This method appends the compressed data for a single zip entry. To load an entire in-memory .zip, call OpenFromMemory instead. Returns a null reference on failure
HCkZipEntry CkZip_AppendData(HCkZip cHandle, const char *fileName, HCkByteData data);
Appends in-memory data as a new entry to a Zip object. The ZipEntry object containing the data is returned. Returns a null reference on failure
HCkZipEntry CkZip_AppendData(HCkZip cHandle, const char *fileName, const char *data, unsigned long dataLen);
Appends in-memory data as a new entry to a Zip object. The ZipEntry object containing the data is returned. Returns a null reference on failure
BOOL CkZip_AppendFiles(HCkZip cHandle, const char *filePattern, BOOL recurse);
Appends one or more files to the Zip object. The filePattern can use the "*" wildcard character for 0 or more of any characterSet recurse equal to True to recursively add all subdirectories, or False to only add files in the current directory. Returns TRUE for success, FALSE for failure.
BOOL CkZip_AppendFilesEx(HCkZip cHandle, const char *filePattern, BOOL recurse, BOOL saveExtraPath, BOOL archiveOnly, BOOL includeHidden, BOOL includeSystem);
Appends one or more files to the Zip object. The filePattern can use the "*" wildcard characters. "*" means 0 or more of any character, and "?" means any single character. Set recurse equal to True to recursively add all subdirectories, or False to only add files in the current directory. Other parameters are to control whether or not the full pathname is included with the Zip entry, or whether files with the Archive, Hidden, or System attributes are included. True = yes, False = no. Returns TRUE for success, FALSE for failure.
HCkZipEntry CkZip_AppendHex(HCkZip cHandle, const char *fileName, const char *data);
Creates a new Zip entry and initializes it with already-compressed data that is hexidecimal encoded. (The ZipEntry.CopyHex method can be used to retrieve the compressed data in Hex format.) Returns a null reference on failure
BOOL CkZip_AppendMultiple(HCkZip cHandle, HCkStringArray fileSpecs, BOOL recurse);
This method is the same as calling AppendFiles multiple times - once for each file pattern in fileSpecs
HCkZipEntry CkZip_AppendNew(HCkZip cHandle, const char *fileName);
Appends a new and empty entry to the Zip object and returns the ZipEntry object. Data can be appended to the entry by calling ZipEntry.AppendData. Returns a null reference on failure
HCkZipEntry CkZip_AppendNewDir(HCkZip cHandle, const char *dirName);
Adds an entry to the zip so that when it unzips, a new directory (with no files) is created. The directory does not need to exist on the local filesystem when calling this method. The dirName is simply a string that is used as the directory path for the entry added to the zip. The zip entry object is returned. Returns a null reference on failure
BOOL CkZip_AppendOneFileOrDir(HCkZip cHandle, const char *fileOrDirName, BOOL saveExtraPath);
Appends a single file or directory to the Zip object.
HCkZipEntry CkZip_AppendString(HCkZip cHandle, const char *fileName, const char *str);
Adds an in-memory string to the Zip object. The Unicode string parameter is converted to the ANSI charset before being added to the Zip. If the Zip were written to disk by calling WriteZip, and later unzipped, the entry would unzip to an ANSI text file. Returns a null reference on failure
HCkZipEntry CkZip_AppendString2(HCkZip cHandle, const char *fileName, const char *str, const char *charset);
To be documented soon. Returns a null reference on failure
BOOL CkZip_AppendZip(HCkZip cHandle, const char *zipFileName);
Adds the contents of another existing Zip file to this Zip object. Returns TRUE for success, FALSE for failure.
void CkZip_CloseZip(HCkZip cHandle);
Closes an open Zip file. This is identical to calling NewZip. (NewZip closes the current Zip file, if open, and initializes the Zip object to be empty. Zip files are only created when WriteZip is called.)
BOOL CkZip_DeleteEntry(HCkZip cHandle, HCkZipEntry entry);
Removes a Zip entry from the calling Zip object. Returns TRUE for success, FALSE for failure.
void CkZip_ExcludeDir(HCkZip cHandle, const char *dirName);
Adds a directory name to be excluded when AppendFiles is called to add an entire directory tree. All directories having a name equal to an excluded directory will not be included when AppendFiles (or AppendFileEx) is called. Multiple directories can be excluded by calling ExcludeDir multiple times.
BOOL CkZip_Extract(HCkZip cHandle, const char *dirPath);
Unzip all the files into the specified directory. Subdirectories are automatically created as needed. Returns TRUE for success, FALSE for failure.
BOOL CkZip_ExtractInto(HCkZip cHandle, const char *dirPath);
Unzips all the files in a Zip into a single directory regardless of the path stored in the Zip Returns TRUE for success, FALSE for failure.
BOOL CkZip_ExtractMatching(HCkZip cHandle, const char *dirPath, const char *pattern);
Unzip all files matching a wildcard pattern. Returns TRUE for success, FALSE for failure.
BOOL CkZip_ExtractNewer(HCkZip cHandle, const char *dirPath);
Extracts only the files that have more recent last-modified-times than the files on disk. This allows you to easily refresh only the files that have been updated. Returns TRUE for success, FALSE for failure.
HCkZipEntry CkZip_FirstEntry(HCkZip cHandle);
Return the first entry in the Zip. Call ZipEntry.NextEntry to iterate over the entries in a Zip until a NULL is returned. Returns a null reference on failure
HCkZipEntry CkZip_FirstMatchingEntry(HCkZip cHandle, const char *pattern);
Returns the first entry having a filename matching a pattern. The "*" characters matches 0 or more of any character. The full filename, including path, is used when matching against the pattern. A NULL is returned if nothing matches. Returns a null reference on failure
void CkZip_GetDirectoryAsXML(HCkZip cHandle, HCkString xml);
Return the contents of the Zip file directory in an XML formatted string
HCkZipEntry CkZip_GetEntryByID(HCkZip cHandle, long entryID);
Retrieves a ZipEntry by ID. Chilkat Zip.NET automatically assigns a unique ID to each ZipEntry in the Zip. This feature makes it easy to associate an item in a UI control with a ZipEntry. Returns a null reference on failure
HCkZipEntry CkZip_GetEntryByIndex(HCkZip cHandle, long index);
Retrieves a ZipEntry by index. The first entry is at index 0. This will return directory entries as well as files. Returns a null reference on failure
HCkZipEntry CkZip_GetEntryByName(HCkZip cHandle, const char *entryName);
Returns a ZipEntry by filename. If a full or partial path is part of the filename, this must be included in the filename parameter. Returns a null reference on failure
HCkStringArray CkZip_GetExclusions(HCkZip cHandle);
Returns the current collection of exclusion patterns that have been set by SetExclusions. Returns a null reference on failure
void CkZip_GetExeConfigParam(HCkZip cHandle, const char *name, HCkString value);
To be documented soon...
HCkZipEntry CkZip_InsertNew(HCkZip cHandle, const char *fileName, long beforeIndex);
Inserts a new and empty entry into the Zip object. To insert at the beginning of the Zip, beforeIndex should be 0. The ZipEntry's FileName property is initialized to fileName parameter. Returns a null reference on failure
BOOL CkZip_IsNoCompressExtension(HCkZip cHandle, const char *fileExtension);
To be documented soon...
BOOL CkZip_IsPasswordProtected(HCkZip cHandle, const char *zipFilename);
Return True if a Zip file is password protected
BOOL CkZip_IsUnlocked(HCkZip cHandle);
Returns True if the class is already unlocked, otherwise returns False.
BOOL CkZip_NewZip(HCkZip cHandle, const char *zipFileName);
Clears and initializes the contents of the Zip object. If a Zip file was open, it is closed and all entries are removed from the object. The FileName property is set to the filename parameter.
BOOL CkZip_OpenEmbedded(HCkZip cHandle, const char *exeFilename, const char *resourceName);
Opens a Zip embedded in an EXE Returns TRUE for success, FALSE for failure.
BOOL CkZip_OpenFromByteData(HCkZip cHandle, HCkByteData byteData);
To be documented soon. Returns TRUE for success, FALSE for failure.
BOOL CkZip_OpenFromMemory(HCkZip cHandle, const unsigned char *zipFileInMemory, unsigned long dataLen);
Open a Zip that is completely in-memory. This allows for Zip files to be opened from non-filesystem sources, such as a database. Returns TRUE for success, FALSE for failure.
BOOL CkZip_OpenFromWeb(HCkZip cHandle, const char *url);
Opens a Zip directly from a URL. The entire contents of the Zip are downloaded and loaded into memory before returning. Returns TRUE for success, FALSE for failure.
BOOL CkZip_OpenMyEmbedded(HCkZip cHandle, const char *resourceName);
Opens a Zip embedded within the caller's EXE. Returns TRUE for success, FALSE for failure.
BOOL CkZip_OpenZip(HCkZip cHandle, const char *zipFileName);
Opens a Zip archive. Encrypted and password-protected zips may be opened without providing the password, but their contents may not be unzipped unless the correct password is provided via the DecryptPassword proprety, or the SetPassword method.
When a zip is opened, the PasswordProtect and Encryption properties will be appropriately set. If the zip is password protected (i.e. uses older Zip 2.0 encrypion), then the PasswordProtect property will be set to true. If the zip is strong encrypted, the Encryption property will be set to a value 1 through 4, where 4 indicates WinZip compatible AES encryption. Returns TRUE for success, FALSE for failure.
BOOL CkZip_QuickAppend(HCkZip cHandle, const char *zipFilename);
Efficiently appends additional files to an existing zip archive. QuickAppend leaves all entries in the existing .zip untouched. It operates by appending new files and updating the internal "central directory" of the zip archive. Returns TRUE for success, FALSE for failure.
BOOL CkZip_RemoveEmbedded(HCkZip cHandle, const char *exeFilename, const char *resourceName);
Removes an embedded Zip from an EXE Returns TRUE for success, FALSE for failure.
void CkZip_RemoveNoCompressExtension(HCkZip cHandle, const char *fileExtension);
Removes a file extension from the zip object's internal list of "no compress" extensions. (For more information, see AddNoCompressExtension.)
BOOL CkZip_ReplaceEmbedded(HCkZip cHandle, const char *exeFilename, const char *resourceName, const char *zipFilename);
Replace a Zip embedded in an EXE with another Zip file. Returns TRUE for success, FALSE for failure.
BOOL CkZip_SaveLastError(HCkZip cHandle, const char *filename);
Saves the last error information to an XML formatted file.
void CkZip_SetCompressionLevel(HCkZip cHandle, int level);
Sets the compression level for all Zip entries. The default compression level is 6. A compression level of 0 is equivalent to no compression. The maximum compression level is 9.
The zip.SetCompressionLevel method must be called after appending the files (i.e. after the calls to AppendFile*, AppendData, or AppendOneFileOrDir).
A single call to SetCompressionLevel will set the compression level for all existing entries.
void CkZip_SetExclusions(HCkZip cHandle, HCkStringArray excludePatterns);
Specify a collection of exclusion patterns to be used when adding files to a Zip. Each pattern in the collection can use the "*" wildcard character, where "*" indicates 0 or more occurances of any character.
void CkZip_SetExeConfigParam(HCkZip cHandle, const char *name, const char *value);
Sets a self-extractor property that is embedded in the resultant EXE created by the WriteExe or WriteExe2 methods. The paramName is one of the XML tags listed in the ExeXmlConfig property.
For example, to specify the text for the self-extractor's main dialog unzip button, paramName would be "MainUnzipBtn".
void CkZip_SetPassword(HCkZip cHandle, const char *password);
Set the password for an encrypted or password-protected Zip.
BOOL CkZip_UnlockComponent(HCkZip cHandle, const char *regCode);
Unlocks the component allowing for the full functionality to be used. Returns true if the unlock code is valid.
int CkZip_Unzip(HCkZip cHandle, const char *dirPath);
Unzips and returns the number of files unzipped, or -1 if a failure occurs. Subdirectories are automatically created during the unzipping process.
int CkZip_UnzipInto(HCkZip cHandle, const char *dirPath);
Unzips and returns the number of files unzipped, or -1 if a failure occurs. All files in the Zip are unzipped into the specfied dirPath regardless of the directory path information contained in the Zip. This has the effect of collapsing all files into a single directory. If several files in the Zip have the same name, the files unzipped last will overwrite the files already unzipped.
int CkZip_UnzipMatching(HCkZip cHandle, const char *dirPath, const char *pattern, BOOL verbose);
Same as Unzip, but only unzips files matching a pattern. If no wildcard characters ('*') are used, then only files that exactly match the pattern will be unzipped. The "*" characters matches 0 or more of any character.
int CkZip_UnzipMatchingInto(HCkZip cHandle, const char *dirPath, const char *pattern, BOOL verbose);
Unzips matching files into a single directory, ignoring all path information stored in the Zip.
int CkZip_UnzipNewer(HCkZip cHandle, const char *dirPath);
Same as Unzip, but only files that don't already exist on disk, or have later file modification dates are unzipped.
BOOL CkZip_VerifyPassword(HCkZip cHandle);
Tests the current DecryptPassword setting against the currently opened zip. Returns true if the password is valid, otherwise returns false.
BOOL CkZip_WriteExe(HCkZip cHandle, const char *filename);
Writes a self-extracting executable. There are no limitations on the total size, individual file size, or number of files that can be added to a self-extracting EXE.
If the resultant EXE will automatically accept these command-line arguments when run:
- -log logFileName
- Creates a log file that lists the settings embedded within the EXE and logs the errors, warnings, and other information about the self-extraction.
- -unzipDir unzipDirectoryPath
- Unzips to this directory path without user intervention.
- -pwd password
- Specifies the password for an encrypted EXE
- -ap autoRunParams
- Specifies the command line parameters to be passed to the AutoRun executable (embedded within the EXE).
Returns TRUE for success, FALSE for failure.
BOOL CkZip_WriteExe2(HCkZip cHandle, const char *exeFilename, const char *outExeFilename, BOOL bAesEncrypt, int keyLength, const char *password);
Writes a self-extracting EXE with no limitations on total file size and no limitations on the size of any one file contained within.
The 1st argument is the pre-existing EXE housing that is to be used. Essentially,
the self-extracting EXE is a concatenation of the EXE housing and the compressed/encrypted data.
The 2nd argument is the name of the EXE to create or overwrite.
A housing for use with WriteExe2 can be found here:
http://www.chilkatsoft.com/d2/SaExtract.zip Returns TRUE for success, FALSE for failure.
BOOL CkZip_WriteExeToMemory(HCkZip cHandle, HCkByteData outBytes);
To be documented soon...
BOOL CkZip_WriteToMemory(HCkZip cHandle, HCkByteData bData);
Same as WriteZip, but instead of writing the Zip to a file, it writes to memory. Zips that are written to memory can also be opened from memory by calling OpenFromMemory.
BOOL CkZip_WriteZip(HCkZip cHandle);
Saves the Zip to a file and implictly re-opens it so further operations can continue. Use WriteZipAndClose to write and close the Zip. There is no limitation on the size of files that may be contained within a .zip, the total number of files in a .zip, or the total size of a .zip. If necessary, WriteZip will use the ZIP64 file format extensions when 4GB or file count limitations of the old zip file format are exceeded. Returns TRUE for success, FALSE for failure.
BOOL CkZip_WriteZipAndClose(HCkZip cHandle);
Saves the Zip to a file and closes it. On return, the Zip object will be in the state as if NewZip had been called. There is no limitation on the size of files that may be contained within a .zip, the total number of files in a .zip, or the total size of a .zip. If necessary, WriteZip will use the ZIP64 file format extensions when 4GB or file count limitations of the old zip file format are exceeded. Returns TRUE for success, FALSE for failure.
const char *CkZip_appendFromDir(HCkZip cHandle);
When files are added to a Zip archive, they are appended from this directory. For example, if you wish to add all the files under c:/abc/123/myAppDir, you might set this property equal to "c:/abc/123", and then pass "myAppDir/*" to AppendFiles.
const char *CkZip_autoRun(HCkZip cHandle);
Optional when creating self-extracting EXEs. This is the name of an executable contained within the to-be-created EXE that will automatically be run after extraction. (This is typically something like "setup.exe")
const char *CkZip_autoRunParams(HCkZip cHandle);
Command line parameters that get passed to the AutoRun executable.
const char *CkZip_decryptPassword(HCkZip cHandle);
When opening a password-protected or AES encrypted Zip, this is the password to be used for decryption. Encrypted Zips may be opened without setting a password, but the contents cannot be unzipped without setting this password.
Note:The SetPassword method has the effect of setting both this property as well as the EncryptPassword property. The SetPassword method should no longer be used. It has been replaced by the DecryptPassword and EncryptPassword properties to make it possible to open an encrypted zip and re-write it with a new password.
const char *CkZip_encryptPassword(HCkZip cHandle);
The password used when writing a password-protected or strong-encrytped Zip.
Note:The SetPassword method has the effect of setting both this property as well as the DecryptPassword property. The SetPassword method should no longer be used. It has been replaced by the DecryptPassword and EncryptPassword properties to make it possible to open an encrypted zip and re-write it with a new password.
const char *CkZip_exeDefaultDir(HCkZip cHandle);
Specifies the default unzip directory path to appear in the user-interface dialog box when the self-extracting EXE is run.
const char *CkZip_exeIconFile(HCkZip cHandle);
Applies to creating self-extracting EXEs. This property can be set to a pre-existing icon filename (.ico) that will be embedded within the to-be-created EXE and set as its default icon.
const char *CkZip_exeSourceUrl(HCkZip cHandle);
This property allows you to create a self-extracting EXE where the data to be extracted is not actually contained within the EXE. Instead, when the self-extracting EXE is run, your zip is downloaded from a URL and unzipped. The self-extracting EXE will automatically use the proxy specified by Internet Explorer if one is defined.
In practice, you would prepare your .zip and place it on your web server at a publicly accessible URL. You may then create and distribute self-extracting EXEs that have this URL embedded. Your zip on the web server may be updated at will, and your already-distributed self-extracting EXEs will always download and unzip the latest files.
const char *CkZip_exeTitle(HCkZip cHandle);
Applies to creating self-extracting EXEs. Sets the title of the main user-interface dialog that appears when the self-extracting EXE runs.
const char *CkZip_exeUnzipCaption(HCkZip cHandle);
Applies to creating self-extracting EXEs. Sets the unzipping caption of the main user-interface dialog that appears when the self-extracting EXE runs.
const char *CkZip_exeUnzipDir(HCkZip cHandle);
Applies to creating self-extracting EXEs. Stores a pre-defined unzip directory within the self-extracting EXE so that it automatically unzips to this directory without user-intervention.
Environment variables may be included if surrounded by percent characters. For example: %TEMP%. Environment variables are expanded (i.e. resolved) when the self-extracting EXE runs.
Note: To create a self-extracting EXE with no user-interaction, set the following properties to these values:
ExeSilentProgress = false
ExeNoInterface = true
ExeFinishNotifier = false
const char *CkZip_exeXmlConfig(HCkZip cHandle);
Allows for an XML config document to be used to specify all possible options for self-extracting EXEs. This property is a string containing the XML config document.
The XML should have this format:
<SfxConfig>
<ErrPwdTitle>Title for incorrect password dialog</ErrPwdTitle>
<ErrPwdCaption>Caption for incorrect password dialog</ErrPwdCaption>
<FinOkBtn>Text on finish notifier button</FinOkBtn>
<PwdOkBtn>Text on password challenge dialog's "OK" button.</PwdOkBtn>
<PwdCancelBtn>Text on password challenge dialog's Cancel button.</PwdCancelBtn>
<ErrInvalidPassword>Incorrect password error message.</ErrInvalidPassword>
<MainUnzipBtn>Text on main dialog's unzip button</MainUnzipBtn>
<MainCloseBtn>Text on main dialog's quit/exit button</MainCloseBtn>
<MainBrowseBtn>Text on main dialog's browse-for-directory button.</MainBrowseBtn>
<MainUnzipLabel>Caption displayed in main dialog.</MainUnzipLabel>
<AutoTemp>"1|0"</AutoTemp>
<ShowFin>"1|0" Maps to ExeFinishNotifier property.</ShowFin>
<ShowMain>"1|0" Maps to ExeNoInterface property.</ShowMain>
<ShowProgress>"1|0" Maps to ExeSilentProgress property.</ShowProgress>
<WaitForSetup>"1|0" Maps to ExeWaitForSetup property.</WaitForSetup>
<Encryption>"1|0" 1=Yes, 0=No</Encryption>
<KeyLength>128|192|256</KeyLength>
<SetupExe>EXE to run after extracting. (Maps to AutoRun property)</SetupExe>
<UnzipDir>Pre-defined unzip directory. (Maps to ExeUnzipDir property)>
<DefaultDir>Default unzip directory to appear in the main dialog.
(Maps to ExeDefaultDir property)</DefaultDir>
<IconFile>Icon file to be used (Maps to ExeIconFile property)</IconFile>
<Url>Maps to ExeSourceUrl property.</Url>
<MainTitle>Maps to ExeTitle property.</MainTitle>
<MainCaption>Maps to ExeUnzipCaption property.</MainCaption>
<FinTitle>Title for the finish notifier dialog.</FinTitle>
<FinCaption>Caption for the finish notifier dialog.</FinTitle>
<ProgressTitle>Title for the progress dialog.</ProgressTitle>
<ProgressCaption>Caption for the progress dialog.</ProgressCaption>
<PwTitle>Title for the password challenge dialog.</PwTitle>
<PwCaption>Caption for the password challenge dialog.</PwCaption>
</SfxConfig>
const char *CkZip_fileName(HCkZip cHandle);
The name of the Zip file. This file is created or overwritten when the Zip is saved.
const char *CkZip_getDirectoryAsXML(HCkZip cHandle);
Return the contents of the Zip file directory in an XML formatted string
const char *CkZip_getExeConfigParam(HCkZip cHandle, const char *name);
To be documented soon...
const char *CkZip_lastErrorHtml(HCkZip cHandle);
Error information in HTML format for the last method called.
const char *CkZip_lastErrorText(HCkZip cHandle);
Error information in plain-text format for the last method called.
const char *CkZip_lastErrorXml(HCkZip cHandle);
Error information in XML format for the last method called.
const char *CkZip_pathPrefix(HCkZip cHandle);
A prefix that is added to each filename when zipping. One might set the PathPrefix to "subdir/" so that files are unzipped to a specified subdirectory when unzipping.
const char *CkZip_proxy(HCkZip cHandle);
(Optional) The name of a proxy to be used with the OpenFromWeb method. Only necessary if your computer uses a proxy to access the Internet. The proxy string should be formatted as "hostname:port", such as "www.chilkatsoft.com:100".
const char *CkZip_tempDir(HCkZip cHandle);
The temporary directory to use when unzipping files. When running in ASP or ASP.NET, the default value of TempDir is set to the directory where the .zip is being written. Set this property to override the default.
const char *CkZip_version(HCkZip cHandle);
The version of the component, such as "v9.0.1"
|