Open()
|
Previous Top Next |
:Open(<cFileName>,
|
[<nOpenMode>],
|
[<nCompression>]) --> lOpened
|
<cFileName>
|
<cFileName> specifies the File Name of the Zip File. This File Name is saved in the Read-Only instance variable :FileName.
|
<nOpenMode>
|
<nOpenMode> optionally specifies the Open Mode for the Zip File. The default value is either: XBZ_OPEN_UPDATE (if the file exists) or XBZ_OPEN_CREATE (if it does not). Possible options are the following Define Constants from the XbZLib.ch file:
|
|
|
|
If <cFileName> does not exist and XBZ_OPEN_UPDATE was specified, the Open Mode will be automatically changed to XBZ_OPEN_CREATE, and a new file will be created.
|
|
If <cFileName> does not exist and either XBZ_OPEN_READ or XBZ_OPEN_TEST was specified, the Open Mode will be changed to XBZ_OPEN_FAILED, and no file will be created or opened.
|
|
If <cFileName> could not be opened (and after it has been closed), the Open Mode will always revert back to XBZ_OPEN_FAILED.
|
|
If the Open Mode XBZ_OPEN_CREATE is explicitly specified, any existing file named <cFileName> will be deleted!
|
|
If either XBZ_OPEN_READ or XBZ_OPEN_TEST is used, then <cFileName> cannot be updated or changed, as it will be opened Read-Only, but it can be read (but not written to) by other applications, until it has been closed with the :Close() method.
|
|
A Zip File that is opened in XBZ_OPEN_CREATE or XBZ_OPEN_UPDATE mode can be updated or changed, but cannot be opened (at all) by other applications, until it has been closed with the :Close() method!
|
|
The current Open Mode is saved in the protected instance variable :nOpenMode, and cannot be accessed from outside the Class. Use the :IsOpen() method instead, to determine the current Open Status.
|
<nCompression>
|
<nCompression> optionally specifies the Default Compression Level for adding/updating (File) Entries to the Zip File with the :AddData() method. This value is saved in the instance variable :Compression.
|
|
Possible options are the following Define Constants from the XbZLib.ch file:
|
|
|
|
Also possible are all integer values between 1 and 9 (for which no define constants exist), which determine the relation between Speed and Compression Ratio and give a finer granulation than the above listed Define values. But in virtually all cases, the Default Compression is the best compromise between compression ratio and speed. Using higher compression ratios will result in only very slightly smaller files, and using a better speed (lower compression ratio) will give only very small improvements in the speed!
|
This method returns .T. (TRUE) if the file could be opened, or .F. (FALSE) if not.
|
This method opens (and/or creates) a Zip File. Using XBZ_OPEN_TEST as <nOpenMode> will also do an automatic Integrity Test and the program will try to automatically fix the Zip File, if any errors were found. See also the :Test() and :Fix() methods and :OnCorruption Callback variable.
|
|
If a Zip File is already open, that Zip File is first closed (and any changes to it are saved if necessary) before the new Zip File is opened/created. None of the other instance variables are reset, though, and an open Log File will stay open and a selected Display object will be kept active!
|
Create a new XbZLibZip object and open Zip File "MyArchive.zip":
|
|
oZip := XbZLibZip():New()
|
oZip:Open('MyArchive.zip')
|