e-CryptIt Engine - Compression Xojo Plugin |

# EinhugurZipArchives.ZipArchiveWriter Class (console safe)

A ZipArchiveWriter class to create a Zip archive.
Note:This class is in EinhugurZipArchives Namespace

ZipArchive
ZipArchiveWriter

class EinhugurZipArchives.ZipArchiveWriter

#### Constructors

ZipArchiveWriter (console safe) | Constructor with no parameters for the ZipArchiveWriter class.

#### Properties

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

#### Methods

AddEmptyDirectory (console safe) | Low level function - Adds a empty directory to the zip archive.
AddFile (console safe) | Adds a file to the zip archive. This variation of the AddFile will add the file at the root in the Zip archive.
AddFile (console safe) | Low level function - Adds a file to the zip archive.
AddFileContent (console safe) | Adds 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.
AddFileContent (console safe) | Low level function - Adds a file contents to the zip archive, taking in parameter to give the file name inside the zip archive.
AddItem (console safe) | Adds a file or a directory recursively to the Zip archive.
AddItem (console safe) | Adds a file or a directory to the Zip archive. This variation has a parameter to choose if you want to add recursively or not.
Close (Inherited) (console safe) | Closes the archive and finalises all unsaved changes.
Create (console safe) | Creates a Zip archive at given location. This constructor will default to normal non zip64 archive.
Create (console safe) | Creates a Zip archive at given location and has parameter to choose if it should be zip64 archive or not.
EntryAt (Inherited) (console safe) | Returns a entry with full details in the Zip Archive at a given index.
EntryIsDirectory (Inherited) (console safe) | Returns true if a entry in the Zip Archive at a given index is a directory, else false.
EntryName (Inherited) (console safe) | Gets name of a entry in the Zip Archive at a given index.

#### Enumerations

CompressionMethodEnum | Enum 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 Intel 64 bit
- macOS Apple Silicon
- Windows 32 bit
- Windows 64 bit
- Windows ARM 64 bit
- Linux 32 bit
- Linux 64 bit
- Linux ARM 32 bit
- Linux ARM 64 bit
- iOS