archive_io library

Classes

AbstractFileHandle
Base class for FileHandle and RamFileHandle. Provides an interface for random access to the data of a file.
AesCtr
AES in counter mode with a 16, 24 or 32 byte key.
AesDecrypt
Archive
/ A collection of files
ArchiveExtension
The extensions a format is written with, without the dot
ArchiveFile
A file contained in an Archive.
Bz2BitReader
Internal class used by BZip2Decoder
Bz2BitWriter
Internal class used by BZip2Encoder
BZip2
Internal class used by BZip2Decoder
BZip2ChunkedDecoder
Decodes a bzip2 stream chunk by chunk.
BZip2ChunkedEncoder
Writes a bzip2 archive over data that arrives in pieces.
BZip2Codec
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
BZip2Decoder
Decompress bzip2 compressed data. Derived from libbzip2 (http://www.bzip.org).
BZip2DecoderConverter
Please note that onDone may never be called on failure, you have to listen for both onError and onDone to identify the end of stream. Example for .decoder:
BZip2Encoder
Compress data using the BZip2 format. Derived from libbzip2 (http://www.bzip.org).
BZip2EncoderConverter
Please note that onDone may never be called on failure, you have to listen for both onError and onDone to identify the end of stream. Example for .encoder:
ChunkDecoder
Decodes an input a chunk at a time, for InputDecodeStream.
ChunkedConverter
A Converter over a ChunkedSink. Whole input conversion goes through the chunked path. ZLibDecoder does the same, so there is one behaviour rather than two
ChunkedSink
A codec that gets bytes as they arrive.
CodecsRecognizer
Detects an archive's format from its first bytes.
Crc64
A running CRC-64 over however many pieces the bytes arrive in, on every backend. The value leaves as eight little endian bytes rather than as an int, since an int does not hold it where dart2js compiles
Deflate
Dart implementation of the ZLib deflate compression algorithm, used by ZLibEncoder and GZipEncoder.
DeflateLevel
Defines some standard compression levels to use for the Deflate algorithm.
FileBuffer
Buffered file reader reduces file system disk access by reading in buffers of the file so that individual file reads can be read from the cached buffer.
FileContent
Used by ArchiveFile to abstract the content of a file within an archive file, either in memory, or a position within a file on disk.
FileContentMemory
A FileContent that is resident in memory.
FileContentStream
A FileContent that is stored in a disk file.
FileHandle
GZipDecoder
Decompress data with the gzip format decoder. The actual decoder used will depend on the platform the code is run on. In a 'dart:io' based platform, like Flutter, the native GZipCodec will be used to improve performance. On web platforms, a Dart implementation of ZLib will be used, via the Inflate class. If you want to force the use of the Dart implementation, you can use the GZipDecoderWeb class.
GZipDecoderWeb
GZipEncoder
Compress data with the GZip format encoder. The actual encoder used will depend on the platform the code is run on. In a 'dart:io' based platform, like Flutter, the native GZipCodec will be used to improve performance. On web platforms, a Dart implementation of ZLib will be used, via the Deflate class. If you want to force the use of the Dart implementation, you can use the GZipEncoderWeb class.
GZipEncoderWeb
HmacSha1
HMAC-SHA1
Inflate
Dart implementation of the ZLib inflate decompression algorithm, used by ZLibEncoder and GZipEncoder. This is used to decompress data that was previously compressed by the Deflate algorithm.
InputDecodeStream
An InputStream over data that is decoded from another stream as it is read.
InputFileStream
Stream in data from a file.
InputMemoryStream
Stream in data from a memory buffer.
InputStream
LzmaDecoder
LZMA compression decoder, used by XZDecoder
OutputFileStream
OutputMemoryStream
OutputStream
ProgressOutputStream
Passes every write to output and calls onProgress with the number of bytes written through it, once per interval bytes and on flush and close. If onProgress throws, it's Exception goes to the zone without stopping the decoder/encoder.
RamFileData
RamFileHandle
RangeDecoder
Implements the LZMA range decoder for LZMADecoder on web targets.
RangeDecoderTable
Probability table used with RangeDecoder.
Sha1
Sha256
SinkOutputStream
The output side of a chunked codec: what a codec's core writes into an OutputStream, sent to a Sink piece by piece.
TarChunkedEncoder
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
TarCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
TarDecoder
Decode a tar formatted buffer into an Archive object. Hard link is decoded as ArchiveFile.symbolicLink with target relative to link folder and ArchiveFile.isHardLink set, so extracted link points to its target
TarDecoderTransformer
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer. It reads one entry at a time and holds one entry's header rather than the whole archive. Content has to be read before the loop moves on, the bytes are gone once it does. What left unread is skipped.
TarEncoder
Encode an Archive object into a tar formatted buffer.
TarEncoderTransformer
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
TarEntry
A single tar entry parsed from a Stream
TarFile
A file entry decoded by TarDecoder.
TarFileEncoder
TarMetadata
Metadata from headers that carry no payload but describe the next entry, such as GNU long names, links, and PAX records. Shared here for both TarDecoder and the streamed reader
Xxh64
The seed is taken as a 64 bit value split into two 32 bit halves
XzChunkedDecoder
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
XzChunkedEncoder
Sink for XzEncoderConverter - buffers at most one LZMA2 chunk of input regardless of archive size
XzCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
XZDecoder
Decodes on the calling isolate. Pass an XZMultithreadOptions to spread the work over isolates, one xz block at a time XZ decode example:
XzDecoderConverter
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
XZEncoder
Compress data using the xz format encoder. This encoder only currently supports uncompressed data.
XzEncoderConverter
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
XZMultithreadOptions<T>
Pass this to the the call to spread it over isolates. You cannot wait for an isolate synchronously, so the call returns an empty result at once and the real result goes to onDone, error is placed inside the onError callback. Without onError a failure goes to onDone as an empty list for decodeBytes/encodeBytes, the same as an empty archive, or as false for decodeStream/encodeStream. XZ decode example:
ZipAesHeader
Internal class used by ZipDecoder.
ZipChunkedEncoder
Writes a zip archive to a Sink entry by entry. When streamed is disabled, it buffers each entry to compute the CRC and sizes for the local header, while streamed, the default, writes them after the payload instead
ZipCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
ZipDecoder
Decode a zip formatted buffer into an Archive object.
ZipDirectory
The internal directory structure for a zip archive, used by ZipDecoder.
ZipEncoder
Encode an Archive object into a Zip formatted buffer.
ZipEncoderTransformer
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
ZipEntryBody
Writes one entry a piece at a time. Call step until it returns false, then finish. This lets a caller pass the bytes on before the whole entry is compressed
ZipFile
A file object used by ZipDecoder.
ZipFileEncoder
ZipFileHeader
Provides information about a file, used by ZipDecoder.
ZLibDecoder
Decompress data with the zlib format decoder. The actual decoder used will depend on the platform the code is run on. In a 'dart:io' based platform, like Flutter, the native ZLibCodec will be used to improve performance. On web platforms, a Dart implementation of ZLib will be used, via the Inflate class. If you want to force the use of the Dart implementation, you can use the ZLibDecoderWeb class.
ZLibDecoderWeb
ZLibEncoder
Compress data with the zlib format encoder. The actual encoder used will depend on the platform the code is run on. In a 'dart:io' based platform, like Flutter, the native ZLibCodec will be used to improve performance. On web platforms, a Dart implementation of ZLib will be used, via the Deflate class. If you want to force the use of the Dart implementation, you can use the ZLibEncoderWeb class.
ZLibEncoderWeb
ZstdChunkedDecoder
Decodes a zstd archive that arrives in pieces.
ZstdChunkedEncoder
Writes one zstd frame over data that arrives in pieces.
ZstdCodec
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
ZstdDecoder
Decompress data with the zstd format decoder.
ZstdDecoderConverter
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
ZstdDictionary
A parsed zstd dictionary, ready to be passed to a decoder.
ZstdEncoder
Compress data with the zstd format encoder
ZstdEncoderConverter
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
ZstdMultithreadOptions<T>
zstd -T. Pass this to the the call to spread it over isolates. You cannot wait for an isolate synchronously, so the call returns an empty result at once and the real result goes to onDone, error is placed inside the onError callback. Without onError a failure goes to onDone as an empty list for decodeBytes/encodeBytes, the same as an empty archive, or as false for decodeStream/encodeStream. XZ decode example:

Enums

ArchiveFormat
What CodecsRecognizer.recognize found from provided file headers
ByteOrder
CompressionType
The format of the compression an ArchiveFile is stored with.
EncryptionType
The type of encryption used to encrypt archive file contents.
FileAccess
TarEntryType
The parsed type flag. Note that older tar files often use an empty field for plain files rather than the standard '0'
XZCheck
Checksum used for compressed data.
ZipEncryptionMode
ZipFileOperation

Constants

bzip2Codec → const BZip2Codec
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
distanceProbsLength → const int
distanceShortOffsets → const List<int>
lengthProbsLength → const int
platformZLibDecoder → const _ZLibDecoder
rangeDecoderImplementation → const String
tarCodec → const TarCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
xzCodec → const XzCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
xzDefaultDictionarySize → const int
Dictionary size written to the block header: stored chunks don't need a dictionary, but decoders require one, and both encoders use the same value so their output is identical
xzDefaultMemoryBudget → const int
How much memory the isolates may hold at once by default, in bytes
zipCodec → const ZipCodec
Not a standard dart:convert Codec because it doesn't perform simple byte-to-byte conversions, acting purely as a StreamTransformer.
zstdCodec → const ZstdCodec
Codec for compressing and uncompressing data that arrives in pieces, the way transform from Stream<List<int>> sends it.
zstdDefaultLevel → const int
zstdDefaultMaxWindowSize → const int
The format allows up to 3.75 TB. This matches the reference decoder's own default ceiling, above which a frame is rejected rather than allocated for
zstdDefaultMemoryBudget → const int
How much memory the isolates may hold at once by default, in bytes
zstdMaxLevel → const int
zstdMinLevel → const int
ZSTD_minCLevel(), the fastest --fast level

Functions

checkZstdMultithreadOptions(ZstdMultithreadOptions<Object?> options) → void
The four fields that describe the work, checked the same way wherever the options arrive: a value no path can honour is a mistake at the call, not a failure of the encode
crc64Bytes(List<int> array) → Uint8List
The check over array whole, for a caller with nothing to keep between pieces
createArchiveFromDirectory(Directory dir, {bool includeDirName = true}) → Archive
createTarFile(String dirPath) → Future<void>
extractArchiveToDisk(Archive archive, String outputPath, {int? bufferSize, bool throwOnError = false, bool allowAbsoluteSymlinks = false, int? maxSize}) → Future<void>
Writes the entries of archive into outputPath
extractArchiveToDiskSync(Archive archive, String outputPath, {int? bufferSize, bool throwOnError = false, bool allowAbsoluteSymlinks = false, int? maxSize}) → void
Writes the entries of archive into outputPath
extractFileToDisk(String inputPath, String outputPath, {String? password, int? bufferSize, ArchiveCallback? callback, bool verify = false, bool? throwOnError, bool allowAbsoluteSymlinks = false, int? maxSize}) → Future<void>
Extracts the archive at inputPath into outputPath
extractTarFiles(String inputPath, String outputPath) → Directory
Extract the entries in the given tar file to a directory.
getAdler32(List<int> array, [int adler = 1]) → int
Get the Adler-32 checksum for the given array. You can append bytes to an already computed adler checksum by specifying the previous adler value.
getAdler32Stream(InputStream stream, [int adler = 1]) → int
getCrc32(List<int> array, [int crc = 0]) → int
Get the CRC-32 checksum of the given array. You can append bytes to an already computed crc by specifying the previous crc value.
getCrc32Byte(int crc, int b) → int
Get the CRC-32 checksum of the given int.
getCrc64(List<int> array, [int crc = 0]) → int
Throws UnsupportedError on dart2js, where int holds 53 bits. Use Crc64 instead, which holds CRC as two 32-bit halves and returns 8 bytes, so it works on every backend without speed downgrade for IO
getInputExtension(String inputPath) → String
inflateBuffer(List<int> data) → FutureOr<Uint8List>?
isCrc64Supported() → bool
False on dart2js, where int holds 53 bits and getCrc64 cannot return 64-bit value. Use Crc64, which holds CRC as two 32-bit halves and returns 8 bytes, so it works on every backend without speed downgrade for IO
listTarFiles(String path) → void
Print the entries in the given tar file.
pbkdf2HmacSha1(Uint8List password, Uint8List salt, int iterations, int length) → Uint8List
PBKDF2-HMAC-SHA1, length bytes of key from password
recognizeArchiveFormat(Uint8List data) → ArchiveFormat
Reads the header of data the way CodecsRecognizer.recognize does
tarHeaderChecksumMatches(Uint8List header) → bool
Validates the 512-byte header against its own checksum (calculated with the checksum field replaced by spaces). Because tar headers lack strict magic numbers, this is the only proof that the block is actually a tar header
xzDictionarySizeValue(int dictionarySize) → int
LZMA2 dictionary size byte: size = (2 + low bit) << (remaining bits + 11), with 40 meaning 4 GiB - 1.
xzMultibyteInteger(int value) → Uint8List
Seven bits per byte, the lowest first

Typedefs

ArchiveCallback = void Function(ArchiveFile entry)
A callback function called when archive entries are read from or written to archive files like zip or tar.
ZipFileProgress = ZipFileOperation Function(FileSystemEntity entity, double progress)

Exceptions / Errors

ArchiveChecksumException
Thrown with verify and throwOnError when data does not match its checksum
ArchiveException
An exception thrown when there was a problem in the archive library.
ArchiveLimitException
Thrown regardless of verify and throwOnError when data exceeds size limit such as maxOutputSize, maxSize or TarFile.maxMetadataSize
ArchiveMacException
Thrown regardless of verify and throwOnError when AES data does not match its MAC
ArchivePasswordException
Thrown regardless of verify and throwOnError when a password is wrong or missing
ZstdDictionaryException