home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / Chip_1998-03_cd.bin / zkuste / delphi / komprese / zip / DELZIP12.ZIP / DOC.ZIP / USAGE.TXT < prev    next >
Text File  |  1997-09-28  |  19KB  |  367 lines

  1.  
  2.    TZipMaster VCL by Eric W. Engler.  v1.20
  3.  
  4.    A Delphi/C++ Builder wrapper for my freeware ZIP and UNZIP DLLs.
  5.  
  6.    A VCL wrapper for my freeware ZIP and UNZIP DLLs.  At run time,
  7.    the DLL's: ZIPDLL.DLL and UNZDLL.DLL must be present on the
  8.    hard disk - in C:\WINDOWS\SYSTEM or else in your application 
  9.    directory, or a directory in the PATH.
  10.  
  11.    These DLLs are based on the InfoZip Official Freeware Zip/Unzip
  12.    source code, but they are NOT equivalent to InfoZip's DLLs.
  13.    I have modified the InfoZip source code to enhance their
  14.    ease-of-use, power, and flexibility for use with Delphi and
  15.    C++ Builder.  Please do NOT contact InfoZip for issues
  16.    regarding this port.
  17.  
  18.    To obtain the official InfoZip source code, consult their
  19.    Web site:
  20.                http://www.cdrom.com/pub/infozip/
  21.  
  22.  
  23.    The five main methods that can be invoked are:
  24.        add      - add one or more files to a ZIP archive
  25.        delete   - delete one or more files from ZIP archive
  26.        extract  - expand one or more files from a ZIP archive
  27.        list     - transfer "table of contents" of ZIP archive
  28.                   to a StringList
  29.        copyfile - copies a file
  30.  
  31.    "add" and "list" will also work on self-extracting ZIP archives
  32.    having a file extension of ".EXE".
  33.  
  34.    Various properties exist to control the actions of the methods.
  35.  
  36.    Filespecs are specified in the FSpecArgs TStringList property, so you
  37.    can easily combine many different filespecs into one Add, Delete, or
  38.    Extract operation. For example:
  39.  
  40.       1. Add entries directly to the FSpecArgs property:
  41.        ZipMaster1.FSpecArgs.Add('C:\AUTOEXEC.BAT');
  42.        ZipMaster1.FSpecArgs.Add('C:\DELPHI\BIN\DELPHI.EXE');
  43.        ZipMaster1.FSpecArgs.Add('C:\WINDOWS\*.INI');
  44.  
  45.       2. Take the filespecs from a StringList, just assign them all over
  46.          to ZipMaster1.
  47.        ZipMaster1.FSpecArgs.Assign(StringList1);
  48.  
  49.       3. Take the filespecs from a ListBox, just assign them all over
  50.          to ZipMaster1.
  51.        ZipMaster1.FSpecArgs.Assign(ListBox1.Items);
  52.  
  53.    You can specify either the MS-DOS backslash path symbol, or the one
  54.    normally used by PKZIP (the Unix path separator: /).  They are treated
  55.    exactly the same.
  56.  
  57.    All of your FSpecArgs accept MS-DOS wildcards.
  58.  
  59.    Add, Delete, and Extract are the only methods that use FSpecArgs.
  60.    The List method doesn't - it just lists all files.
  61.  
  62.  
  63.    Following is a list of all TZipMaster properties, events and methods:
  64.  
  65.    Properties
  66.    ==========
  67.      Verbose      Boolean     If True, ask for the maximum amount of "possibly
  68.                               important" information from the DLLs.  The
  69.                               informational messages are delivered to your
  70.                               program via the OnMessage event, and the ErrCode
  71.                               and Message properties. This is primarily used
  72.                               to determine how much info you want to show your
  73.                               "end-users" - developers can use the Trace
  74.                               property to get additional infomation.
  75.  
  76.      Trace        Boolean     Similar to Verbose, except that this one is
  77.                               aimed at developers.  It lets you trace the
  78.                               execution of the C code in the DLLs.  Helps
  79.                               you locate possible bugs in the DLLs, and
  80.                               helps you understand why something is happening
  81.                               a certain way.
  82.  
  83.      ErrCode      Integer     Holds a copy of the last error code sent to
  84.                               your program by from DLL. 0=no error.
  85.                               See the OnMessage event.  Most messages from
  86.                               the DLLs will have an ErrCode of 0.
  87.  
  88.      Message      String      Holds a copy of the last message sent to your
  89.                               program by the DLL.  See the OnMessage event.
  90.  
  91.      ZipContents  TList       Read-only TList that contains the directory
  92.                               of the archive specified in the ZipFileName
  93.                               property. Every entry in the list points to
  94.                               a ZipDirEntry record.  This is automatically
  95.                               filled with data whenever an assignment is
  96.                               made to ZipFileName, and can be manually
  97.                               filled by calling the List method.
  98.                                  For your convenience, this VCL hides the
  99.                               TList memory allocation issues from you.
  100.                                  Automatic updates to this list occur
  101.                               whenever this VCL changes the ZIP file.
  102.                               Event OnDirUpdate is triggered for you
  103.                               each time this list is updated - that is
  104.                               your queue to refresh your directory display.
  105.  
  106.    ---------------------------------------------------------------------
  107.    Each entry in the ZipContents TList is a ZipDirEntry record:
  108.  
  109.    ZipDirEntry = packed Record
  110.      Version                     : WORD;
  111.      Flag                        : WORD;
  112.      CompressionMethod           : WORD;
  113.      DateTime                    : Longint; { Time: Word; Date: Word; }
  114.      CRC32                       : Longint;
  115.      CompressedSize              : Longint;
  116.      UncompressedSize            : Longint;
  117.      FileNameLength              : WORD;
  118.      ExtraFieldLength            : WORD;
  119.      FileName                    : String;
  120.    end;
  121.  
  122.    To get compression ratio:
  123.    (code from Almer Tigelaar, tigelaar@tref.nl)
  124.    var
  125.       ratio: Integer;
  126.    begin
  127.       with ZipDirEntry1 do
  128.          ratio:=Round((1-(CompressedSize/UnCompressedSize))*100);
  129.    ---------------------------------------------------------------------
  130.  
  131.      Cancel       Boolean     If you set this to True, it will abort any
  132.                               Add or Extract processing now underway.  There
  133.                               may be a slight delay before the abort will
  134.                               take place.  Note that a ZIP file can be
  135.                               corrupted if an Add operation is aborted.
  136.  
  137.      ZipBusy      Boolean     If True, a ZIP operation is underway - you
  138.                               must delay your next Add/Delete operation
  139.                               until this is False.  You won't need to be
  140.                               concerned about this in most applications.
  141.                               This can be used to syncronize Zip operations
  142.                               in a multi-threaded program.
  143.  
  144.      UnzBusy      Boolean     If True, an UNZIP operation is underway -
  145.                               you must delay your next Extract operation
  146.                               until this is False.  You won't need to be
  147.                               concerned about this in most applications.
  148.                               This can be used to syncronize UnZip
  149.                               operations in a multi-threaded program.
  150.  
  151.      AddCompLevel Integer     Compression Level.  Range 0 - 9, where 9
  152.                               is the tightest compression.  2 or 3 is a
  153.                               good trade-off if you need more speed. Level 0
  154.                               will just store files without compression.
  155.                               I recommend leaving this at 9 in most cases.
  156.  
  157.      AddOptions   Set         This property is used to modify the default
  158.                               action of the Add method.  This is a SET of
  159.                               options.  If you want an option to be True,
  160.                               you need to add it to the set.  This is
  161.                               consistant with the way Delphi deals with
  162.                               "options" properties in general.
  163.  
  164.         AddDirNames           If True, saves the pathname with each fname.
  165.                               Drive IDs are never stored in ZIP file 
  166.                               directories. NOTE: the root directory name is
  167.                               never stored in a pathname; in other words, 
  168.                               the first character of a pathname stored in 
  169.                               the zip file's directory will never be a slash.
  170.  
  171.         AddForceDOS           If True, force all filenames that go into
  172.                               the ZIP file to meet the DOS 8x3 restriction.
  173.                               If false, long filenames are supported.
  174.                               WARNING: name conflicts can occur if 2 long
  175.                               filenames reduce to the same 8x3 filename!
  176.  
  177.         AddZipTime            If True, set ZIP timestamp to that of the newest
  178.                               file in the archive.
  179.  
  180.         AddRecurseDirs        If True, subdirectories below EACH given fspec
  181.                               will be included in the fspec. Defaults to False.
  182.                               This is potentially dangerous if the user does
  183.                               this from the root directory (his hard drive
  184.                               may fill up with a huge zip file)!
  185.  
  186.         AddHiddenFiles        If True, files with their Hidden or System
  187.                               attributes set will be included in the Add 
  188.                               operation. 
  189.  
  190.         NOTE: You can not have more than one of the following three options
  191.               set to "True".  If all three are False, then you get a standard
  192.               "add": all files in the fspecs will be added to the archive
  193.               regardless of their date/time stamp.  This is also the default.
  194.  
  195.         AddMove               If True, after adding to archive, delete orig
  196.                               file.  Potentially dangerous.  Use with caution!
  197.  
  198.         NOTE: Freshen and Update can only work on pre-existing archives. Update
  199.         can add new files to the archive, but can't create a new archive.
  200.  
  201.         AddFreshen            If True, add newer files to archive (only for
  202.                               files that are already in the archive).
  203.  
  204.         AddUpdate             If True, add newer files to archive (but, any
  205.                               file in an fspec that isn't already in the
  206.                               archive will also be added).
  207.  
  208.      ExtrBaseDir  String      This base directory applies only to "Extract"
  209.                               operations.  The UNZIP DLL will "CD" to this
  210.                               directory before extracting any files. If you
  211.                               don't specify a value for this property, then the
  212.                               directory of the ZipFile itself will be the
  213.                               base directory for extractions.
  214.  
  215.      ExtrOptions  set         This property is used to modify the default
  216.                               action of the Extract method.  This is a SET
  217.                               of options.  If you want an option to be
  218.                               True, you need to add it to the set.
  219.  
  220.         ExtrDirNames          If True, extracts and recreates the relative
  221.                               pathname that may have been stored with each file.
  222.                               Empty dirs stored in the archive (if any) will
  223.                               also be recreated.
  224.  
  225.         ExtrOverWrite         If True, overwrite any pre-existing files during
  226.                               Extraction.
  227.  
  228.         ExtrFreshen           If True, extract newer files from archive (only 
  229.                               for files that already exist).  Won't extract
  230.                               any file that isn't already present.
  231.  
  232.         ExtrUpdate            If True, extract newer files from archive (but,
  233.                               also extract files that don't already exist).
  234.  
  235.      FSpecArgs    TStrings    Stringlist containing all the filespecs used
  236.                               as arguments for Add, Delete, or Extract
  237.                               methods. Every entry can contain MS-DOS wildcards.
  238.                               If you give filenames without pathnames, or if
  239.                               you use relative pathnames with filenames, then
  240.                               the base drive/directory is assumed to be that
  241.                               of the Zipfile.
  242.  
  243.      ZipFileName  String      Pathname of a ZIP archive file.  If the file
  244.                               doesn't already exist, you will only be able to
  245.                               use the Add method.  I recommend using a fully
  246.                               qualified pathname in this property, unless
  247.                               your program can always ensure that a known
  248.                               directory will be the "current" directory.
  249.  
  250.      Count        Integer     Number of files now in the Zip file.  Updated
  251.                               automatically, or manually via the List method.
  252.  
  253.      SuccessCnt   Integer     Number of files that were successfully
  254.                               operated on (within the current ZIP file).
  255.                               You can read this after every Add, Delete, and
  256.                               Extract operation.
  257.  
  258.      ZipVers      Integer     The version number of the ZIPDLL.DLL.  For
  259.                               example, 110 = version 1.10.
  260.  
  261.      UnzVers      Integer     The version number of the UNZDLL.DLL.  For
  262.                               example, 110 = version 1.10.
  263.                            
  264.    Events
  265.    ======
  266.      OnDirUpdate              Occurs immed. after this VCL refreshes it's
  267.                               TZipContents TList.  This is your queue to
  268.                               update the screen with the new contents.
  269.  
  270.      OnProgress               Occurs during compression and decompression.
  271.                               Intended for "status bar" or "progress bar"
  272.                               updates.  Criteria for this event:
  273.                                 - starting to process a new file (gives you
  274.                                     the filename and total uncompressed
  275.                                     filesize)
  276.                                 - every 32K bytes while processing
  277.                                 - completed processing on a batch of files
  278.                               See Demo1 to learn how to use this event.
  279.  
  280.      OnMessage                Occurs when the DLL sends your program a message.
  281.                               The Message argument passed by this event will
  282.                               contain the message. If an error code
  283.                               accompanies the message, it will be in the
  284.                               ErrCode argument.
  285.                                  The Verbose and Trace properties have a
  286.                               direct influence on how many OnMessage events
  287.                               you'll get.
  288.                                  See Also: Message and ErrCode properties.
  289.  
  290.    Methods
  291.    =======
  292.      Add                      Adds all files specified in the FSpecArgs
  293.                               property into the archive specified by the
  294.                               ZipFileName property. 
  295.                                 Files that are already compressed will not be
  296.                               compressed again, but will be stored "as is" in
  297.                               the archive. This applies to .GIF, .ZIP, .LZH,
  298.                               etc. files. Note that .JPG files WILL be
  299.                               compressed, since they can still be squeezed
  300.                               down in size by a notable margin.
  301.  
  302.      Extract                  Extracts all files specified in the FSpecArgs
  303.                               property from the archive specified by the
  304.                               ZipFilename property. If you don't specify
  305.                               any FSpecArgs, then all files will be extracted.
  306.  
  307.      Delete                   Deletes all files specified in the FSpecArgs
  308.                               property from the archive specified by the
  309.                               ZipFilename property.
  310.  
  311.      List                     Refreshes the contents of the archive into 
  312.                               the ZipContents TList property.  This is
  313.                               a manual "refresh" of the "Table of Contents".
  314.  
  315.      CopyFile                 This copies any file to any other file.
  316.                               Useful in many application programs, so 
  317.                               it was included here as a method.  This returns
  318.                               0 on success, or else one of these errors:
  319.                                   -1   error in open of outfile
  320.                                   -2   read or write error during copy
  321.                                   -3   error in open of infile
  322.                                   -4   error setting date/time of outfile
  323.                               Can be used to make a backup copy of the 
  324.                               ZipFile before an Add operation.
  325.                               Sample Usage:
  326.                                 with ZipMaster1 do
  327.                                 begin
  328.                                    ret=CopyFile(ZipFileName, 'C:\TMP$$.ZIP');
  329.                                    if ret < 0 then
  330.                                       ShowMessage('Error making backup');
  331.                                 end;
  332.  
  333.      IMPORTANT note regarding CopyFile: The destination must include
  334.      a filename (you can't copy fname.txt to C:\).  Also, Wildcards are
  335.      not allowed in either source or dest.
  336.  
  337.    --------------------------------------------------------------------
  338.                        DLL Loading and Unloading
  339.  
  340.    This table show you which DLL is needed for each method:
  341.  
  342.        Add        requires ZIPDLL.DLL
  343.        Delete     requires ZIPDLL.DLL
  344.        Extract    requires UNZDLL.DLL
  345.        List         none   (internal code in this VCL)
  346.        CopyFile     none   (internal code in this VCL)
  347.  
  348.    The following 4 methods give you explicit control over loading and
  349.    unloading of the DLLs.  For simplicity, you can do the loads in
  350.    your form's OnCreate event handler, and do the unloads in your
  351.    form's OnDestroy event handler.
  352.    
  353.       Load_Zip_Dll    --  Loads ZIPDLL.DLL, if not already loaded
  354.       Load_Unz_Dll    --  Loads UNZDLL.DLL, if not already loaded 
  355.       Unload_Zip_Dll  --  Unloads ZIPDLL.DLL
  356.       Unload_Unz_Dll  --  Unloads UNZDLL.DLL
  357.  
  358.    For compatibility with older programs, and because I'm a nice
  359.    guy, I'll handle the loads and unloads automatically if your
  360.    program doesn't do it.  This can, however, incur a perfomance 
  361.    penalty because it will reload the needed DLL for each operation.
  362.  
  363.    Advanced developers will want to carefully consider their load
  364.    and unload strategy so they minimize the number of loads, and
  365.    keep the DLLs out of memory when they're not needed. There is a
  366.    traditional speed vs. memory trade-off.
  367.