e-CryptIt Engine - Compression Xojo Plugin

ZipArchiveWriter.AddItem Method

Adds a file or a directory recursively to the Zip archive.

AddItem(
   item as FolderItem,
   compressionMethod as CompressionMethodEnum,
   progress as ZipArchive.ProgressDelegate)

Parameters

item
The file or directory to be added.
compressionMethod
Compression method. This can be any one of the constant from the CompressionMethodEnum on this class.
progress
Optional parameter that takes progress delegate. Default value is nil.

Remarks

This function is high level function that internally uses the lower level functions.

If you want to make custom handling for this then the AddItem is equal to the following code:

Sub AddItem(zip as EinhugurZipArchives.ZipArchiveWriter,f as FolderItem,compressionMethod as EinhugurZipArchives.ZipArchiveWriter.CompressionMethodEnum)
    if not f.Alias then
       if f.Directory then
          AddItemRecursive(zip,f,f.Name + "/",compressionMethod)
       else
          zip.AddFile(f,"",compressionMethod)
       end if
    end if
End Sub

Sub AddItemRecursive(zip as EinhugurZipArchives.ZipArchiveWriter,f as FolderItem,path as String, compressionMethod as EinhugurZipArchives.ZipArchiveWriter.CompressionMethodEnum)
    Dim itemCount as Integer
    Dim item as FolderItem
    Dim extendedPath as String
   
    itemCount = f.Count
   
    if itemCount = 0 then
       zip.AddEmptyDirectory(path + f.Name + "/","")
    else
      
       for i as Integer = 1 to itemCount
          item = f.Item(i)
         
          if not item.Alias then
            
             if item.Directory then
                AddItemRecursive(zip,item,path + item.Name + "/" ,compressionMethod)
             else
                zip.AddFile(item,path,"",compressionMethod)
             end if
            
          end if
       next
      
    end if
End Sub

See Also

ZipArchiveWriter Class