e-CryptIt Engine - Compression Xojo Plugin

EinhugurZipArchives.ZipArchiveWriter Class

A ZipArchiveWriter class to create a Zip archive.

Note:This class is in EinhugurZipArchives Namespace

ZipArchive
   ZipArchiveWriter

class EinhugurZipArchives.ZipArchiveWriter

Constructors

ZipArchiveWriterConstructor with no parameters for the ZipArchiveWriter class.

Properties

EntryCount (Inherited) Count of entries in the zip archive.
IsOpen (Inherited) Returns true if the archive is open else false.
IsZip64 (Inherited) Returns true if the zip archive is Zip64 archive, else false.
LastError (Inherited) Returns the last error that occurred by last operation that was executed or zero if no error.

Methods

AddEmptyDirectoryLow level function - Adds a empty directory to the zip archive.
AddFileAdds a file to the zip archive. This variation of the AddFile will add the file at the root in the Zip archive.
AddFileLow level function - Adds a file to the zip archive.
AddFileContentLow level function - Adds a file contents to the zip archive, taking in parameter to give the file name inside the zip archive.
AddFileContentAdds a file contents to the zip archive, taking in parameter to give the file name inside the zip archive. This variation of the AddFileContent will add the file at the root in the Zip archive.
AddItemAdds a file or a directory to the Zip archive. This variation has a parameter to choose if you want to add recursively or not.
AddItemAdds a file or a directory recursively to the Zip archive.
Close (Inherited) Closes the archive and finalises all unsaved changes.
CreateCreates a Zip archive at given location. This constructor will default to normal non zip64 archive.
CreateCreates a Zip archive at given location and has parameter to choose if it should be zip64 archive or not.
EntryAt (Inherited) Returns a entry with full details in the Zip Archive at a given index.
EntryIsDirectory (Inherited) Returns true if a entry in the Zip Archive at a given index is a directory, else false.
EntryName (Inherited) Gets name of a entry in the Zip Archive at a given index.

Enumerations

CompressionMethodEnumEnum with constants that defines how much to compress. The lower compression value that is used the faster it gets but the file compresses less. 0 to 9 are standard compression levels where 9 is the most and 0 is no compression. 10 is less compatible compression strategy but compresses more in many cases.

Notes

Note:
Since this class is in namespace then you address it like this:

Dim zip as EinhugurZipArchives.ZipArchiveWriter


or

using EinhugurZipArchives

Dim zip as ZipArchiveWriter



Compress directory example:
using EinhugurZipArchives

Dim f as FolderItem
Dim directoryToCompress as FolderItem
Dim zip as ZipArchiveWriter
Dim counter as Integer

// Select some folder to compress
directoryToCompress = SelectFolder()

if directoryToCompress = nil then
    return
end if

// Find name for the new zip file that is not taken
// --------------------------------------------------------------------
while f = nil or f.Exists
    if counter = 0 then
       f = directoryToCompress.Parent.Child(directoryToCompress.Name + ".zip")
       counter = 1
    else
       f = directoryToCompress.Parent.Child(directoryToCompress.Name + Str(counter) + ".zip")
    end if
   
    counter = counter + 1
wend
// --------------------------------------------------------------------


zip = new EinhugurZipArchives.ZipArchiveWriter()

zip.Create(f)

if zip.IsOpen then
    zip.AddItem(directoryToCompress,ZipArchiveWriter.CompressionMethodEnum.BEST_COMPATIBLE_COMPRESSION)
   
    zip.Close()
else
    MsgBox "Could not open file"
end if


Known limitations:
Encrypted entries are not supported.
Apple and Microsoft extensions for special file flags are not supported.
Multi disk files are not supported.
No old style MacOS 9 resource forks are supported

Supported Platforms:

  • MacOS X Cocoa 32 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM

    Unsupported Platforms:

  • MacOS X Carbon