FileManager
extension FileManager
-
Zips the file or direcory contents at the specified source URL to the destination URL.
If the item at the source URL is a directory, the directory itself will be represented within the ZIP
Archive. Calling this method with a directory URLfile:///path/directory/will create an archive with adirectory/entry at the root level. You can override this behavior by passingfalseforshouldKeepParent. In that case, the contents of the source directory will be placed at the root of the archive.Throws
Throws an error if the source item does not exist or the destination URL is not writable.Declaration
Swift
public func zipItem(at sourceURL: URL, to destinationURL: URL, shouldKeepParent: Bool = true, compressionMethod: CompressionMethod = .none, progress: Progress? = nil) throwsParameters
sourceURLThe file URL pointing to an existing file or directory.
destinationURLThe file URL that identifies the destination of the zip operation.
shouldKeepParentIndicates that the directory name of a source item should be used as root element within the archive. Default is
true.compressionMethodIndicates the
CompressionMethodthat should be applied.progressA progress object that can be used to track or cancel the zip operation.
View on GitHub
FileManager Extension Reference