Skip to content

Releases: tsolomko/SWCompression

4.1.0 Test 1

03 Jan 16:50
4.1.0-test.1
22372cb
Compare
Choose a tag to compare
4.1.0 Test 1 Pre-release
Pre-release

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

25 Nov 15:46
4.0.1
f57a9e0
Compare
Choose a tag to compare
  • 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

18 Nov 10:36
v4.0.0
36f068e
Compare
Choose a tag to compare

Reworked "Container" API

There is a couple of ideas behind this rework:

  1. Enforce in API the idea that one can get information about entries without acquiring their data, but not vice versa.
  2. Provide a unified set of API for all three formats: ZIP, TAR and 7-Zip.
  3. 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 and type.

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 and data 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 type Info: 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 type Entry: ContainerEntry.
  • open function now returns an array of associated type Entry.
  • Added new function info which returns an array of Entry.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 and SevenZipEntry now have only two members: info and data (in accordance with ContainerEntry protocol).
  • Standardised behaviour when ContainerEntry.data can be nil:
    • 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. Use type property instead.
  • SevenZipEntryInfo.name is no longer Optional.
    • 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.

Common Types

Added several new common types which are used across the framework:

  • CompressionMethod.
    • Used as a type of compressionMethod property of GzipHeader, ZlibHeader and ZipEntryInfo.
    • Removed GzipHeader.CompressionMethod.
  • ContainerEntryType.
    • Used as a type of type property of ContainerEntryInfo.
    • Removed TarEntry.EntryType.
  • DosAttributes.
    • It is the same as SevenZipEntryInfo.DosAttributes type from previous version.
    • Used as a type of dosAttributes property of SevenZipEntryInfo and ZipEntryInfo.
  • Permissions.
    • It is the same as SevenZipEntryInfo.Permissions type from previous version.
    • Used as a type of permissions property of ContainerEntryInfo.
  • FileSystemType.
    • Used as a type of GzipHeader.osType and ZipEntryInfo.fileSystemType properties.
    • Removed GzipHeader.FileSystemType.

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 to BZip2Error.wrongHuffmanCodeLength.
    • BZip2Error.wrongCompressionMethod to BZip2Error.wrongVersion.
    • TarError.fieldIsNotNumber to TarError.wrongField.
    • XZError.reservedFieldValue to XZError.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.
    • 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.

General changes

  • Renamed XZArchive.multiUnarchive to XZArchive.splitUnarchive.
  • XZArchive.unarchive now processes all XZ streams similar to splitUnarchive, but combines them into one output Data.

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

11 Nov 10:40
v4.0.0-test.2
50ac2f0
Compare
Choose a tag to compare
4.0.0 Test 2 Pre-release
Pre-release
  • Changes to Errors:
    • Removed:
      • SevenZipError.dataIsUnavailable
      • LZMAError.decoderIsNotInitialised
      • LZMA2Error.wrongProperties (LZMA2Error.wrongDictionarySize is thrown instead.)
    • Renamed BZip2Error.wrongHuffmanLengthCode to BZip2Error.wrongHuffmanCodeLength.
  • ContainerEntryInfo.name is no longer Optional.
    • 7z now throws internalStructureError when it is unable to process file names.
  • Various FileSystemType variables are no longer Optional.
    • They have .other value where it was nil previously.
  • TarEntryInfo.linkName is no longer Optional.
  • Fixed "bitReader is not aligned" precondition crash in Zlib.
  • ZlibHeader.compressionMethod now uses common CompressionMethod enum instead of its own.

4.0.0 Test 1

05 Nov 09:43
v4.0.0-test.1
f71d345
Compare
Choose a tag to compare
4.0.0 Test 1 Pre-release
Pre-release

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

03 Oct 19:28
v3.4.0
7c03fc7
Compare
Choose a tag to compare
  • 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.
  • Added CompressionAlgorithm protocol.
  • Deflate now conforms to CompressionAlgorithm protocol (as well as BZip2).
  • Deflate.compress(data:) and ZlibArchive.archive(data:) no longer throw, but can crash with fatalError().
    Comment: Though unlikely to happen, it seems more logical to crash with fatalError() 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

02 Oct 20:22
v3.4.0-test.2
8881c60
Compare
Choose a tag to compare
3.4.0 Test 2 Pre-release
Pre-release
  • Fixed compile problems on some platforms (iOS, watchOS).
    Comment: These problems are related to the fact that on those platforms Int is 32-bit instead of 64-bit.

3.4.0 Test

01 Oct 21:44
v3.4.0-test
9d2852c
Compare
Choose a tag to compare
3.4.0 Test Pre-release
Pre-release

Main focus of this upcoming release is the addition of BZip2 compression.

3.3.1

01 Oct 08:36
v3.3.1
da2fbab
Compare
Choose a tag to compare
  • 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 of Data and was returning some value. Now, it causes a crash.

3.3.0

20 Aug 07:53
v3.3.0
1137046
Compare
Choose a tag to compare

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 and ZipEntry.linkPath properties.
  • Added isLink and linkPath properties to ContainerEntry 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 in TarEntry.entryAttributes containing UNIX type byte in some cases.
  • Renamed build flags included in CocoaPods configurations.