ZipUtilities

ZipUtilities is a powerful library that allows developers to work with zip archives in their iOS applications. With its easy-to-use interface and comprehensive set of features, ZipUtilities simplifies the process of compressing and decompressing files, creating and extracting zip archives, and managing their contents.

Key Features

  • Compression and decompression of files
  • Creation and extraction of zip archives
  • File management within zip archives
  • Password protection for zip archives
  • Support for zip64 format
  • Progress tracking during zip operations
  • Support for both zip and gz file formats
  • High performance and low memory footprint

Installation

To integrate ZipUtilities into your iOS project, you can use CocoaPods. Simply add the following line to your Podfile:

pod 'ZipUtilities'

Then run the pod install command in your terminal or shell.

If you prefer manual installation, you can download the latest release from the official GitHub repository (https://github.com/ziputils/ZipUtilities) and add the necessary files to your project.

Usage

Compression

To compress a file or a directory, use the following code:

// Import the ZipUtilities module
import ZipUtilities

// Compress a file
try ZipUtilities.compressFile(at: fileURL, to: destinationURL)

// Compress a directory
try ZipUtilities.compressDirectory(at: directoryURL, to: destinationURL)

Decompression

To decompress a zip archive, use the following code:

// Import the ZipUtilities module
import ZipUtilities

// Decompress a zip archive
try ZipUtilities.decompressFile(at: zipURL, to: destinationURL)

Zip Archive Management

ZipUtilities provides various methods to work with zip archives:

// Import the ZipUtilities module
import ZipUtilities

// Get the list of files and directories within a zip archive
let fileList = try ZipUtilities.contentsOfArchive(at: archiveURL)

// Check if a file exists within a zip archive
let fileExists = try ZipUtilities.fileExists(withinArchive: archiveURL, filePath: "path/to/file.txt")

// Extract a specific file from a zip archive
try ZipUtilities.extractFile(fromArchive: archiveURL, filePath: "path/to/file.txt", to: destinationURL)

// Password protect a zip archive
try ZipUtilities.setPassword("secretPassword", forArchive: archiveURL)

// Check if a zip archive is password protected
let isPasswordProtected = try ZipUtilities.isPasswordProtected(at: archiveURL)

Progress Tracking

To track the progress of a zip operation, you can implement the ZipUtilitiesProgressDelegate protocol and assign a delegate to observe the progress:

// Import the ZipUtilities module
import ZipUtilities

// Assign a delegate to track the progress
ZipUtilities.progressDelegate = self

// Implement the ZipUtilitiesProgressDelegate protocol methods
class YourViewController: UIViewController, ZipUtilitiesProgressDelegate {
    func zipProgressDidChange(progress: Double) {
        print("Zip operation progress: \(progress * 100)%")
    }
    // ...
}

Zip64 Support

ZipUtilities offers support for the Zip64 format, which allows handling large zip archives exceeding the traditional size limit. For operations involving Zip64 archives, use the provided methods:

// Import the ZipUtilities module
import ZipUtilities

// Compress a file using Zip64 format
try ZipUtilities.compressFile(at: fileURL, to: destinationURL, useZip64: true)

// Check if a zip archive is Zip64 format
let isZip64Format = try ZipUtilities.isZip64Format(at: archiveURL)

Supported File Formats

ZipUtilities supports both the zip and gz file formats for compression and decompression operations.

Conclusion

ZipUtilities is a valuable library for any iOS developer looking to handle zip archives in their applications seamlessly. Its powerful features, ease of use, and exceptional performance make it an ideal choice for managing compressed files efficiently. Feel free to explore the extensive documentation and examples provided in the official GitHub repository: https://github.com/ziputils/ZipUtilities.