⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zipunzip.pas

📁 script language
💻 PAS
📖 第 1 页 / 共 4 页
字号:
Unit ZipUnzip;
(* TZipMaster VCL by Chris Vleghert and Eric W. Engler v1.52M  Jun. 6, 2000.
   e-mail: cvleghrt@WorldOnline.nl
   www:    http://www.geocities.com/SiliconValley/Orchard/8607/ or
   www:    http://members.tripod.lycos.nl/Vleghert/

  Changes in v1.52m:
   -in ReadSpan a Zip archive comment was not handled as it should have been. bug solved
    thanks to Tim Borman.
   -Moved DLL handles and function pointers variables to ZipMaster private in stead
    of as global variables. This should avoid problems with automatic DLL loading and
    unloading when using threads.
   -Uses now ZipVers.inc

  Changes in v1.52l:
   -Add the Current directory to the EraseFile method when no path is set.
    (Recycle won't work without a fully qualyfied path.)
   -Now D5 compatible

  Changes in v1.52k:
   -Fixed a bug in the ZipDll that prevented the use of the Add option AddForceDOS.
   -Fixed a bug in the ZipDll that prevented the use of the Add option AddZipTime.
   -Fixed a bug in the SFX source code, re-compilation always resulted in the message
    Error reading Archive File. Found thanks to Patrick Gentemann.
   -Added a new Read Only property VersionInfo.
   -Fixed the message: 'Error reading ZipMaster1.AddStoresSuffixes: Property does not exist.'
    when opening some demo projects.
   -Moved the assignment of the FErrCode and FMessage one line up in the function ShowExceptionError
    This way the property ErrCode can be used inside the OnMessage event handling. (The parameter
    ErrCode in this event is sometimes 0 while ErrCode is not.)

  Changes in v1.52j:
   -Changed StrPCopy functions to StrPLCopy because of a bug in BCB1, Delphi2 and
    Delphi3 in these environments max. 255 characters are copied, reported by Tim Borman.
   -Added a line to WriteSpan to correctly read and write an existing archive comment.
    Found by Tim Borman.

  Changes in v1.52i:
   -Bug fix in List, ReadSpan to read to correct data when a disk change was neccessary.
    This prevented to open and read a spanned archive which had it's header data split
    across multiple disk(files). Found thanks to Alexander Hofmann.
   -Moved FreeLibrary which wasn't always called in DiskFreeAndSize.
   -Added a SetErrorMode because it wasn't always reset in IsDiskPresent.
   -Changed the function DirExists a little in case the given dir was an empty string. [Range error]
   -Added some properties to the SortGrid VC and as result removed some code from the demos.
   -A new constant UNZIPVERSION 160, now Zip and Unzip dll may have different version numbers.

  Bug Fixes in v1.52h:
   -In the function CheckForDisk in a format specifier '/n...' was used in stead of #13#10.
    thanks to Greg Nixon.
   -In the function WriteSplit a statement was missing that incremented the disk to use.
    This was most likely to happen when zipping to a large spanned archive, but also smaller
    archives could suffer from this this problem.
    thanks to Jim Hoops, Alexander Hofmann.

   Bug Fixes in v1.52g:
   -Small addition to IsRightDisk function to make it possible to open files with UNC prefix.
    (this should have been there in the e version but somehow it did not.)
   -Fixed a memory leak in CheckIfLastDisk thanks to Greg Lorriman.

   Version f Added Russian language support

   Bug Fix and change in v1.52e:
   -Better support for harddisks > 2Gb and UNC names.
    (Replacement function for DiskFree and DiskSize functions this also
     prevented opening files given with an UNC name.)

   Bug Fixes in v1.52d:
   -Reading of spanned disks written by WinZip did not work.

   Bug Fixes in v1.52c:
   -The messages DS_NotaDrive and DS_DriveNoMount expects a string as
    parameter but did in fact get an Integer and as result you would get
    a message: UnKnown error in function ReadSpan() or WriteSpan()
    Now there is an new exception constructor for these messages.
    Found by Tim Borman
   -When there was no disk in the drive no question was asked to put
    one in, instead an exception was raised an the spanning was aborted.
    Found by Tim Borman
   -If the size of the disk is not yet known there was still a question
    to put disk X of Y in the drive. Now this is changed in just Disk X.
    Not really a bug but annoying, Found by Tim Borman
    (Not translated yet)
   -The copy stage of the diskspan process is now a little faster.
    Thanks to Tim Borman
   -The function DiskSize returns in D4 an Int64 instead of an Integer.
    found by Sebastian Hildebrandt

   Bug Fix in v1.52b:
   -While using DiskSpan in encrypted mode an error 'A Local Header
    Signature is wrong' or 'A Central Header Signature is wrong' was given.
    Found by Sam Chan.

   Bug Fixes in v1.52a:
   -Changed the search direction for the EOC record.
    (If there was a zip file stored in a ziparchive within the last 64K
     the wrong archive directory was shown.)
   -Diskspanning with formatting with ConfirmErase = True did not work.

   Changed after Beta3
   - Changed Try Finally in Try Except in the Dll load procedures
     This could cause an exception when the dll's were not found in
     Demo1 and Demo 6.
   - Application.ProcessMessages() in the callback.
   - Formatting done differently because in W'98 an application could
     hang when an other task was started (Bug reported by Teus de Jong
     and Raymond Allan).
   - Demos 1 and 6 statusbar changed a little.
   - Demo6 changed ReadBttnClick; two backslashes were removed.
   - Added fNoRecurseFiles to the ZipParms1 and ZipParms2 record.
   - Removed the 4096 filespecification limit for Extract (and Test) method.
     (Also changed UnzDll.dll now version 1.52)
   - Added a check, in EraseFile(), if the file we want to delete is present
     on disk, SHFileOperation complains if a file does not exists while
     DeleteFile as used before did not.
     This was a problem in ReadSpan(), bug reported by Raymond Allan.

   Changed after Beta2
     Improvements suggested by: Teus de Jong (teusjdejong@wxs.nl)
   - In ConvertZip, ConvertSFX, CopyFile and ReadSpan the old files are no
     longer automaticly deleted. By using the new property HowToDelete its
     possible to choose: htdFinal or htdAllowUndo.
   - Above change lead to a new function which is also made public:
     EraseFile( FileName: String; How: DeleteOpts ): Integer;
   - A special check is made for WinZip self extracting files because they contain
     almost always garbage after the EOC record. This caused a 'very annoying'
     message and although technical speaking it was right, no message is given
     anymore.
   - Small name change of two members in ZipDirEntry record.

   *****************************************************************************
   Changed after Beta1 release 150.

   - During ReadSpan() and WriteSpan() there were still forward slashes showing.
   - ReadSpan() and WriteSpan() were declared private, now public.
   - New record passing to the ZipDll if version >= 151 needed to implement
     TempDir.
   - Changed ZipDll.dll version 151 to accommodate the TempDir property.
     Also prepared for future expansion.
   - Improved error handling in UnzDll.dll version 151.

   Bugs found and improvements suggested by:
     Teus de Jong (teusjdejong@wxs.nl)
   - DeleteSpanMem() caused, in some cases, an Access Violation, this
     occured before MDZD was created in ReadSpan and WriteSpan.
   - New property IsSpanned to indicate if an opened archive is a spanned one.
   - If there was an error in ReadSpan() the output file, that was not complete
     at that moment, was not deleted.
   - In ConvertSFX() and ConvertZip() the In-Out file size check changed in case
     there is garbage at the end of the file.

   Added some extra members to the ZipDirEntry record on request from:
    Almer.S. Tigelaar (almer-t@usa.net)
     . MadeByVersion
     . HostVersionNo
     . FileCommentLen
     . StartOnDisk
     . IntFileAttrib
     . ExtFileAttrib
     . RelOffLocalHdr

   *****************************************************************************

   The changes for this version were mostly done by Chris Vleghert
   (cvleghrt@worldonline.nl). Chris has doubled the size and scope of
   this project. In the past Chris did the BCB port, but now he is
   expanding and may take over the whole project soon!
   This is great news for most of us, because I simply don't have
   time to keep adding new features.


                         General Info About Codepages
                         ----------------------------
      Many programmers don't understand codepages.  These are basically
      just a character set.  The standard MS-DOS character set used
      codepage 850, which is called the "OEM" codepage.  I think Windows
      3.1 used this codepage also.  Most Windows 95 and Windows NT systems
      use codepage 1252, which is for America and Western Europe.  This one
      is called "ISO 8859-1, Latin 1", which I will call "ISO".  There are
      other ISO codepages, but I want to limit this discussion to 8859-1.

      Both the ISO and OEM codepages support the common accented charaters
      used in Western Europe.  However, the exact codes used for specific
      characters are differant.  Each of these also has some unique
      characters in the range $80-$9f.  We would like to be able to convert
      the accented character codes in the filenames when we extract them
      from a zip file.

      In these two codepages, ISO and OEM, the bottom 128 codes are the
      same.  Only the upper 128 codes are different.  These upper codes
      are used for accented characters, and box-drawing symbols, etc.
      Most ZIP files use only the lower 128 codes in their filenames, so
      the codepage used (of the two we support) is irrelevant.  It is only
      important when the non-English accented characters (or other upper
      codes) are used in filenames.

      Each zip file header includes an indicator of which Operating System
      (OS) was used when it was created.  We assume that the current OS is
      Win 95/98/NT using codepage 1252.  If the zip file was made on MS-DOS
      or Win 3.1 (codepage 850), then we can translate it so the extracted
      filenames will appear correctly.  Note that this conversion is not
      100% accurate because each of these character sets has some unique
      symbols.

      This is not an ideal world, though, and many zip files do not
      correctly identify which OS was used to make them.  And, even if we
      know the OS it was made on, they may not have used codepage 850,
      and we may not be using codepage 1252 right now!  So, I allow 4
      different settings of the CodePage property so you can have full
      control over conversions.

      In this release, you do not have the ability to convert text files
      made with one codepage to another codepage.  At this time, you can
      only convert filenames and zip file comments.

      What about the other codepages: Korean, Japanese, Hebrew, etc?
      I don't know any way of translating those codes to codepage 1252,
      because most of their characters do not exist in codepage 1252.
      However, if you are using the Korean codepage, and the people
      you give your zip files to are also using the Korean codepage,
      then no translation is necessary!  If you want to make a zip file
      for use by people in other countries, then you should make it
      using codepage 1252.
      ----------------------------------------------------------------

   Quick summary of changes in version 1.50:

   New properties:
      CodePage: values are cpAuto, cpNone or cpOEM.  This
             determines what character set translation to perform.
             This only affects extraction, and directory listing.
             The items that are translated: filenames/paths, and
             zip file comments.  Contents of files inside the zip
             archive can NOT be converted in this release.
         cpAuto - Attempt to determine automatically when a conversion
                  is needed between codepages 850 and 1252, and do it.
                  This option has proven to be unreliable in some
                  cases, so be careful!. The problem archives were
                  made by Norton Zip, which does not create the zip
                  file header correctly. This is the default.
         cpNone - do not make any conversions. This means we use the
                  local ISO code page to display regardless of how
                  it is stored in the zip file.
         cpOEM  - force OEM to ISO translation.

      New options for AddOptions:
         AddSeparateDirs - if set, add separate entries to the zip archive
              that will hold the name of each directory (no data for these
              entries).  To use this, you must also have AddZipDirs set.

         AddDiskSpan - if set, create a disk-spanning archive if there
              is not enough disk space on the specified drive

         AddDiskSpanErase - if set, create a disk-spanning archive if there
              is not enough disk space on the specified drive.  This option
              pops up a "format disk" dialog every time the user is prompted
              for the next disk (including the first disk).  Of course,
              this option can NOT be used on non-removable drives (user
              will get an error msg if he tries to use this option on a non-
              removable hard drive).

         NOTE: If AdddiskSpan or AddDiskSpanErase is set, you can NOT
            also use AddFreshen or AddUpdate, and you can not create an
            .EXE (SFX Self-extracting) archive. Also, you can not use
            "Unattended" mode to make disk-spanning archives.

     The following properties support disk-spanning:

      TempDir:  name of a temporary directory (full path).  This is
         optional.  If you don't set this, the Windows temp dir will be used.

      KeepFreeOnDisk1:  how many bytes you want left free on the first
         disk.  This gives you room for a setup/install program.

      MaxVolumeSize:  how much of each disk we can use.  If 0, then
         we will use as much as we can of each disk.

      MinFreeVolumeSize:  do not use a disk unless it has at least this
         many bytes free when we start.

      ConfirmErase:  true if you want us to warn the user before we
         erase (format) a disk.

         Due to our new support for disk-spanning, we had to change the way
      zip file directories are read.  In the past, we have used the local
      directory entries, but now we use the central directory entries.  For
      a set of disks, the central directory is usually on the last disk in
      the set.  One problem with doing business this way, is that we can't
      extract or list ANY files of a damaged archive.
         If you have a damaged archive, you can try to fix it with
      PKZIPFIX.EXE (one of the programs that comes with the MS-DOS PKZIP
      release).  We may write a program similar to this in the future.  The
      basic idea is to rebuild the central directory with info from the
      local directory entries.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -