Releases: tsolomko/SWCompression
4.1.0 Test 1
The first part of changes planned for 4.1.0 is extraction of some code from SWCompression into a separate project. This was done recently and you can now check out the new project, BitByteData.
The purpose of this test release is to test integration of this new external dependency into SWCompression.
4.0.1
- Starting with this update, git tags for releases no longer have "v" prefix, since absence of such prefix is a common practice among Swift developers.
- Fixed incorrectly thrown
XZError.wrongDataSize
without actually trying to decompress anything. - Fixed crash when opening 7-Zip containers with more than 255 entries with empty streams.
- Reduced memory usage by Deflate compression.
- Improved performance in some extreme cases (e.g. containers with an enormous amount of entries).
- No longer verify if ZIP string field needs UTF-8 encoding, if language encoding flag is set for the entry.
- Added "perf-test" command to swcomp, which is used for measuring performance. See Results document for the new tests results.
4.0.0
Reworked "Container" API
There is a couple of ideas behind this rework:
- Enforce in API the idea that one can get information about entries without acquiring their data, but not vice versa.
- Provide a unified set of API for all three formats: ZIP, TAR and 7-Zip.
- Try to fix mistakes that were made in the development of previous versions.
Implementation of these ideas led to a lot of changes and here I will try to highlight most of them.
- New protocol:
ContainerEntryInfo
.- It contains some informational properties from the previous version of
ContainerEntry
. - There are also new properties such as
access/creation/modificationTime
andtype
.
- It contains some informational properties from the previous version of
Comment: I would like to encourage you to check out this protocol's documentation as well as types that implement it: SevenZipEntryInfo
, TarEntryInfo
and ZipEntryInfo
.
These types not only have protocol's properties, but also contain their own format-specific members which may be useful in certain cases.
ContainerEntry
now has only two members:info
anddata
properties.
Comment: All properties that existed in previous versions were either removed or moved to ContainerEntryInfo
. One may also note that entry's data is now acquired through constant property rather than function. This means that it is no longer possible to asynchronously unpack ZIP containers, but it worth mentioning, that it was never intended in the first place.
ContainerEntry
now has an associated typeInfo: ContainerEntryInfo
.ContainerEntry.entryAttributes
removed without replacement.
Comment: One may note that it is not a SWCompression's job to prepare entry's properties for the file system. Besides that, its existence was causing duplication of entry's information, so, in the end, it is for the best for this property to go.
Container
now has an associated typeEntry: ContainerEntry
.open
function now returns an array of associated typeEntry
.- Added new function
info
which returns an array ofEntry.Info
.
Comment: One of the useful consequences of these changes is that it is no longer necessary to cast the result of open(container:)
to specific entry type (such as ZipEntry
).
- All existing ZIP, TAR and 7-Zip types conform to these protocols.
- Added missing types for ZIP, TAR and 7-Zip with conformances to these protocols.
ZipEntry
,TarEntry
andSevenZipEntry
now have only two members:info
anddata
(in accordance withContainerEntry
protocol).- Standardised behaviour when
ContainerEntry.data
can benil
:- If entry is a directory.
- If data is unavailable, but error wasn't thrown for some reason.
- 7-Zip only: if entry is an anti-file.
- Removed
SevenZipEntryInfo.isDirectory
. Usetype
property instead. SevenZipEntryInfo.name
is no longerOptional
.- Now throws
SevenZipError.internalStructureError
when file names cannot be properly processed. - Entries now have empty strings as names when no names were found in container.
- Now throws
Common Types
Added several new common types which are used across the framework:
CompressionMethod
.- Used as a type of
compressionMethod
property ofGzipHeader
,ZlibHeader
andZipEntryInfo
. - Removed
GzipHeader.CompressionMethod
.
- Used as a type of
ContainerEntryType
.- Used as a type of
type
property ofContainerEntryInfo
. - Removed
TarEntry.EntryType
.
- Used as a type of
DosAttributes
.- It is the same as
SevenZipEntryInfo.DosAttributes
type from previous version. - Used as a type of
dosAttributes
property ofSevenZipEntryInfo
andZipEntryInfo
.
- It is the same as
Permissions
.- It is the same as
SevenZipEntryInfo.Permissions
type from previous version. - Used as a type of
permissions
property ofContainerEntryInfo
.
- It is the same as
FileSystemType
.- Used as a type of
GzipHeader.osType
andZipEntryInfo.fileSystemType
properties. - Removed
GzipHeader.FileSystemType
.
- Used as a type of
Errors
- Removed following errors:
SevenZipError.dataIsUnavailable
LZMAError.decoderIsNotInitialised
LZMA2Error.wrongProperties
(LZMA2Error.wrongDictionarySize
is thrown instead).TarError.wrongUstarVersion
.TarError.notAsciiString
(TarError.wrongField
is thrown instead).XZError.wrongFieldValue
(XZError.wrongField
is thrown instead).
- Renamed following errors:
BZip2Error.wrongHuffmanLengthCode
toBZip2Error.wrongHuffmanCodeLength
.BZip2Error.wrongCompressionMethod
toBZip2Error.wrongVersion
.TarError.fieldIsNotNumber
toTarError.wrongField
.XZError.reservedFieldValue
toXZError.wrongField
.
- Standardised behaviour for errors with names similar to
wrongCRC
:- These errors mean that everything went well, except for comparing the checksum.
- Their associated values now contain all "successfully" unpacked data, including the one which caused checksum error.
- This change affects
BZip2.decompress
,GzipArchive.multiUnarchive
,XZArchive.unarchive
,XZArchive.splitUnarchive
,ZipContainer.open
.
- This change affects
- Some of these errors now have arrays as associated values to account for the situations with unpacked data being split.
- This change affects
GzipArchive.multiUnarchive
,XZArchive.unarchive
,XZArchive.splitUnarchive
,ZipContainer.open
.
- This change affects
General changes
- Renamed
XZArchive.multiUnarchive
toXZArchive.splitUnarchive
. XZArchive.unarchive
now processes all XZ streams similar tosplitUnarchive
, but combines them into one outputData
.
Comment: These two changes are made to fix intended but apparently incorrect behaviour from previous versions, which was causing inconveniences with some archives.
- Fixed "bitReader is not aligned" precondition crash in Zlib.
- Fixed potential incorrect behavior when opening ZIP containers with size bigger than 4 GB.
- Updated to use Swift 4.
- Various improvements to documentation.
- "swcomp" is now included as part of this repository.
Comment: This was done to make it easier to synchronise changes between SWCompression and swcomp, if necessary. "swcomp" is not built by default.
4.0.0 Test 2
- Changes to Errors:
- Removed:
SevenZipError.dataIsUnavailable
LZMAError.decoderIsNotInitialised
LZMA2Error.wrongProperties
(LZMA2Error.wrongDictionarySize
is thrown instead.)
- Renamed
BZip2Error.wrongHuffmanLengthCode
toBZip2Error.wrongHuffmanCodeLength
.
- Removed:
ContainerEntryInfo.name
is no longerOptional
.- 7z now throws
internalStructureError
when it is unable to process file names.
- 7z now throws
- Various
FileSystemType
variables are no longerOptional
.- They have
.other
value where it wasnil
previously.
- They have
TarEntryInfo.linkName
is no longerOptional
.- Fixed "bitReader is not aligned" precondition crash in Zlib.
ZlibHeader.compressionMethod
now uses commonCompressionMethod
enum instead of its own.
4.0.0 Test 1
Upcoming 4.0.0 update will include major rework of "Container API" as well as changes here and there. It will also have some internal changes which are tested by this test release.
3.4.0
- Implementation of BZip2 compression algorithm.
- There is also an auxiliary function
BZip2.compress(data:blockSize:)
if you need to specify size of input data block. - Default block size is 100 Kilobytes.
- There is also an auxiliary function
- Added
CompressionAlgorithm
protocol. Deflate
now conforms toCompressionAlgorithm
protocol (as well asBZip2
).Deflate.compress(data:)
andZlibArchive.archive(data:)
no longer throw, but can crash withfatalError()
.
Comment: Though unlikely to happen, it seems more logical to crash withfatalError()
when problems occur during compression instead of error throwing because it indicates there is a problem with the code itself, not with the input data.- Fixed crash in some rare cases for corrupted BZip2 archives. It now throws
BZip2Error
instead.
3.4.0 Test 2
- Fixed compile problems on some platforms (iOS, watchOS).
Comment: These problems are related to the fact that on those platformsInt
is 32-bit instead of 64-bit.
3.4.0 Test
Main focus of this upcoming release is the addition of BZip2 compression.
3.3.1
- Fixed an "index out of range" crash.
Comment: Apparently, Swift 3.2 (which is a part of Swift 4) corrected particular behaviour which one may call undefined. Previously, Swift allowed access to out of bounds elements ofData
and was returning some value. Now, it causes a crash.
3.3.0
7-Zip Support
This update introduces support for opening containers in 7-Zip format, though some features aren't supported:
- encryption,
- additional streams,
- external,
- StartPos property of files,
- compression methods with multiple streams,
- filters and some compression methods.
Moreover, some new ideas about API for containers are explored with 7-Zip. For example, there is a separate function info(:)
and class SevenZipEntryInfo
which are used to get only information about files in container without also decompressing file's data. Some or all of these ideas are likely to be applied to both ZIP and TAR in SWCompression 4.0.
Other changes
- Added
TarEntry.isLink
property. - Added
ZipEntry.isLink
andZipEntry.linkPath
properties. - Added
isLink
andlinkPath
properties toContainerEntry
protocol, because all three entry classes have these properties. - Added
ZipEntry.isTextFile
which is based on 'internalFileAttrbiutes' in ZIP container. - Added support for NTFS extra fields in ZIP containers, which contain modification, creation and access time and date in ZIP containers created on Windows.
- Detection of UTF-8 in ZIP string fields now favours Code Page 437.
Comment: In last update special algorithm was added to detect whether string fields in ZIP container such as file name and comment are encoded with UTF-8 encoding or CP437. This was necessary because ZIP files created by Info-ZIP use UTF-8 but don't indicate this in their flags. Unfortunately, previous implementation in cases preferred UTF-8 when a string could be encoded both with UTF-8 and CP437. Now it is changed to CP437 preference to be more in line with ZIP specification. - Fixed undefined behaviour when several
ZipEntry.data()
function calls for entries from the same container were executed in parallel threads (i.e. concurrently). - Fixed
posixPermissions
inTarEntry.entryAttributes
containing UNIX type byte in some cases. - Renamed build flags included in CocoaPods configurations.