tar
2.1.0, released 6 days ago by simonbinder.eu
Memory-efficient, streaming implementation of the tar file format
WASM-readyRock solid
What it does
Provides stream-based readers and writers for tar files. It supports various tar formats including v7, ustar, pax, gnu, and star archives, along with handling long file names.
AI-written summary of version 2.0.3, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to read or write large tar archives in a memory-efficient way
- You are working with streams of bytes to process archives on the fly
Skip it when
- You need synchronous tar parsing from standard buffers without streams
- You need automatic security validation against path traversal attacks (like ../) when extracting untrusted archives
Strengths
- Consumes considerably less memory than package:archive when handling large files
- Hardened against denial-of-service attacks with invalid tar file headers
- Supports compilation to JavaScript and runs on Node.js
Weaknesses
- Slightly slower than alternative buffered implementations due to async stream overhead
- Does not automatically validate against malicious path traversal or tar bombs in untrusted archives
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
import 'dart:convert';
import 'dart:io';
import 'package:tar/tar.dart';
Future<void> main() async {
final reader = TarReader(File('file.tar').openRead());
while (await reader.moveNext()) {
final entry = reader.current;
print(entry.header.name);
print(await entry.contents.transform(utf8.decoder).first);
}
}Alternatives
Packages that do the same job and could replace tar.
Works with
Packages commonly used together with tar: ones it builds on, ones built on it, and its own family.
- asynctar depends on itUtility classes and helpers that extend Dart's async library.
- typed_datatar depends on itUtility functions and classes for easier work with dart:typed_data lists.
- skills_lintBuilt on tarStatic analysis linter and CLI tool for Agent Skills (SKILL.md) structure and metadata
- realm_dartBuilt on tarOfficial Realm database SDK for Flutter and Dart to store and query objects locally.
- dartleBuilt on tarA Dart-based task runner and build system for defining and executing tasks.