tag | 5f9a43fa305e9519d0e476f481b5f6cbd2830543 | |
---|---|---|
tagger | Brendan Duncan <brendanduncan@gmail.com> | Sat Jun 01 02:41:36 2024 |
object | f1d164f8f5d8aea0be620a9b1e8d300b75a29388 |
commit | f1d164f8f5d8aea0be620a9b1e8d300b75a29388 | [log] [tgz] |
---|---|---|
author | Brendan Duncan <brendanduncan@gmail.com> | Sat Jun 01 02:41:21 2024 |
committer | Brendan Duncan <brendanduncan@gmail.com> | Sat Jun 01 02:41:21 2024 |
tree | b943e290eb90eba1116063e24e1439828b8c2b60 | |
parent | 519d79fe99ac7231597e15209db60f57ab026e1c [diff] |
Update version to 3.6.1
A Dart library to encode and decode various archive and compression formats.
The archive library currently supports the following decoders:
And the following encoders:
There are two versions of the Archive library:
package:archive/archive.dart
package:archive/archive_io.dart
archive.dart
are included in archive_io.dart
.The archive_io library contains classes and functions for accessing the file system. These classes and functions can significantly reduce memory usage for decoding archives directly to disk.
import 'package:archive/archive_io.dart'; // ... // Use an InputFileStream to access the zip file without storing it in memory. final inputStream = InputFileStream('test.zip'); // Decode the zip from the InputFileStream. The archive will have the contents of the // zip, without having stored the data in memory. final archive = ZipDecoder().decodeBuffer(inputStream); // For all of the entries in the archive for (var file in archive.files) { // If it's a file and not a directory if (file.isFile) { // Write the file content to a directory called 'out'. // In practice, you should make sure file.name doesn't include '..' paths // that would put it outside of the extraction directory. // An OutputFileStream will write the data to disk. final outputStream = OutputFileStream('out/${file.name}'); // The writeContent method will decompress the file content directly to disk without // storing the decompressed data in memory. file.writeContent(outputStream); // Make sure to close the output stream so the File is closed. outputStream.close(); } }
extractFileToDisk
is a convenience function to extract the contents of an archive file directory to an output directory. The type of archive it is will be determined by the file extension.
import 'package:archive/archive_io.dart'; // ... extractFileToDisk('test.zip', 'out');
extractArchiveToDisk
is a convenience function to write the contents of an Archive to an output directory.
import 'package:archive/archive_io.dart'; // ... // Use an InputFileStream to access the zip file without storing it in memory. final inputStream = InputFileStream('test.zip'); // Decode the zip from the InputFileStream. The archive will have the contents of the // zip, without having stored the data in memory. final archive = ZipDecoder().decodeBuffer(inputStream); extractArchiveToDisk(archive, 'out');