AAR composition

Contents
[ Hide Show ]

Overview

Apple Archive (.aar) is an archive format used on Apple platforms. Aspose.ZIP for .NET can create Apple Archive files with the Aspose.Zip.Apple API, using settings that are applied to newly added entries.

Aspose.ZIP supports Apple Archive composition with uncompressed Store entries or entries compressed with LZMA, Zlib, LZ4, or LZFSE. Use AppleArchiveEntrySettings to choose the compression settings and to control whether file entries include CRC32 checksum fields.

Create archive

The following examples show how to compose an Apple Archive with a single entry. Pass an AppleArchiveEntrySettings instance to the AppleArchive constructor to define compression for newly created entries.

LZMA

1    int blockSize = 1 << 22;      // 4 MiB
2    int dictionarySize = 1 << 23; // 8 MiB
3
4    using (AppleArchive archive = new AppleArchive(new AppleArchiveEntrySettings(new AppleLzmaCompressionSettings(blockSize, dictionarySize))))
5    {
6        archive.CreateEntry("alice29.txt", "alice29.txt");
7        archive.Save("archive.aar");
8    }

LZ4

1    int blockSize = 1 << 20; // 1 MiB
2
3    using (AppleArchive archive = new AppleArchive(new AppleArchiveEntrySettings(new AppleLz4CompressionSettings(blockSize))))
4    {
5        archive.CreateEntry("alice29.txt", "alice29.txt");
6        archive.Save("archive.aar");
7    }

LZFSE

1    int blockSize = 1 << 22; // 4 MiB
2
3    using (AppleArchive archive = new AppleArchive(new AppleArchiveEntrySettings(new AppleLzfseCompressionSettings(blockSize))))
4    {
5        archive.CreateEntry("alice29.txt", "alice29.txt");
6        archive.Save("archive.aar");
7    }

Zlib

1    using (AppleArchive archive = new AppleArchive(new AppleArchiveEntrySettings(new AppleZlibCompressionSettings())))
2    {
3        archive.CreateEntry("alice29.txt", "alice29.txt");
4        archive.Save("archive.aar");
5    }

Store

Pass AppleCompressionSettings.Store to keep entries uncompressed. Set IncludeCrc32Checksum to false if you do not need CRC32 fields for composed file entries:

1    using (AppleArchive archive = new AppleArchive(new AppleArchiveEntrySettings(AppleCompressionSettings.Store) { IncludeCrc32Checksum = false }))
2    {
3        archive.CreateEntry("alice29.txt", "alice29.txt");
4        archive.Save("archive.aar");
5    }