-
Notifications
You must be signed in to change notification settings - Fork 16
Getting Started
SevenZip provides a dead simple, Objective-C/Swift API for managing 7zip files. There are just 2 classes you have to know about:
This is a handle to a 7z archive, both when it already existed and when it has just been created. For existing archives the entries
array is populated immediately with the contents of the opened file. For new archives entries
is obviously empty.
SVZArchive
exposes the archive contents in the form of SVZArchiveEntry
objects, and this is also the type you have to use for adding new entries. SVZArchive
's entries
are a snapshot of the archive contents at the time of opening it and can become out-of-sync if the file is modified in the meantime by some other process.
When creating an SVZArchiveEntry
manually, a snapshot is taken of the file attributes but reading the file contents is deferred until the next call to -[SVZArchive updateEntries:error:]
(in Swift, SVZArchive.updateEntries(_:)
). This behavior might change in future versions.
In the current implementation, SVZArchiveEntry
objects are not reusable and are rendered invalid after the next updateEntries
call. This means that you must throw away any such objects and use the new ones exposed on SVZArchive
. It is not possible, either, to have entries transferred from one open archive to another.
NOTE: the code is not thread-safe, in case of concurrent accesses you have to take care of the synchronization yourself.