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
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
AddEmptyDirectory | Low level function - Adds a empty directory to the zip archive. |
AddFile | Adds a file to the zip archive. This variation of the AddFile will add the file at the root in the Zip archive. |
AddFile | Low level function - Adds a file to the zip archive. |
AddFileContent | Low level function - Adds a file contents to the zip archive, taking in parameter to give the file name inside the zip archive. |
AddFileContent | 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. |
AddItem | 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. |
AddItem | Adds a file or a directory recursively to the Zip archive. |
Close (Inherited) | Closes the archive and finalises all unsaved changes. |
Create | Creates a Zip archive at given location. This constructor will default to normal non zip64 archive. |
Create | Creates 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
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 X Cocoa 32 bitMacOS X Cocoa 64 bitWindows 32 bitWindows 64 bitLinux 32 bitLinux 64 bitLinux ARMUnsupported Platforms:
MacOS X Carbon