Reader for TAR and TAR+GZip Archives, optimized for read huge size archives, effective memory usage.
- Read TAR archives from disk
- Support GZipped and BZipped archives
- Iterate over Archive content
- Get name, size and type of each file
- Recognize Directory files type
- Recognize Regular files type
- Get content of files
- Allows to export content to files
- Optimized for performance and low-memory
- Use stream-first access - file content not stored to memory
composer require jakubboucek/tar-stream-reader
Read files from an archive:
use JakubBoucek\Tar;
foreach (new Tar\FileReader('example.tar') as $file) {
echo "File {$file->getName()} is {$file->getSize()} bytes size, content of file:\n";
echo $fileInfo->getContent() . "\n";
}
Package recognizes few types of Archive when using classic filename extension (e.g.: .tar
, .tgz
, .tar.bz2
), but
You can explicitly define archive type thought second parameter:
use JakubBoucek\Tar;
foreach (new Tar\FileReader('example.tar+gzip', new Tar\Filehandler\Gzip()) as $file) {
echo "File {$file->getName()} is {$file->getSize()} bytes size.\n";
}
Package allows to process any type of stream, use StreamReader
instead of FileReader
:
use JakubBoucek\Tar;
$stream = someBeatifulFuntionToGetStream();
foreach (new Tar\StreamReader($stream) as $file) {
echo "File {$file->getName()} is {$file->getSize()} bytes size.\n";
}
No, Package recognize only TAR Archive format, additionaly recognize GZipped or BZipped Archive.
No, Package provide only read possibility.
No, TAR Archive is stream-based format, it does not support search, you must always iterate over whole Archive.
Here are two scopes of this question: Archive size or Size of files in Archive
- Archive size is teoretically unlimited, beacuse package is using stream very effective.
- Size of files in Archive is teoretically unlimited when use steam-based method to extraxt content
(
toFile()
ortoStream()
), otherwise is size limited with available memory, because is content filled into variable.
Please don't hesitate send Issue or Pull Request.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.