e-CryptIt Engine - Compression Xojo Plugin

ZipArchiveReader.ExtractFileFromEntryIndex Method

Extracts file from a given index in the ZipArchive

ExtractFileFromEntryIndex(
   index as UInt32,
   destination as FolderItem)

Parameters

index
The index of the entry in the zip archive. First entry is number zero.The index of the entry in the zip archive. First entry is number zero.
destination
The destination where to extract to.

Remarks

The LastError property can give hint on success or what error was generated.

ExtractFileFromEntryIndex is a high level method that just uses internally the lower level functions of this plugin. If wanting to customise the ExtractFileFromEntryIndex then our implementation for ExtractFileFromEntryIndex is equal to this code here:

Sub ExtractFileFromEntryIndex(zip as EinhugurZipArchives.ZipArchiveReader, index as UInt32,destination as FolderItem)
    Dim f as FolderItem
    Dim part as String
    Dim pathParts() as String
    Dim pathPartsUbound as Integer
    Dim path as String
   
    f = destination
   
    path = zip.EntryName(index)
    pathParts = path.Split("/")
   
    pathPartsUbound = pathParts.Ubound()
   
    for i as integer = 0 to pathPartsUbound
       part = pathParts(i)
      
       if i = 0 and part = "__MACOSX" then
          return
       end if
      
       if part.Len > 0 then
          f = f.Child(part)
         
          if not f.Exists then
             if i = pathPartsUbound then
                #if TargetWin32
                   zip.ExtractToFile(index, f)
                #else
                   zip.ExtractToFile(index, f)
                #endif
               
             else
                f.CreateAsFolder()
             end if
          end if
       end if
    next
End Sub

See Also

ZipArchiveReader Class