Skip to content

Commit

Permalink
Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubboucek committed Jun 18, 2023
1 parent 3d2992c commit 9cd27b1
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ Reader for TAR and TAR+GZip Archives, optimized for read huge size archives, eff
## Features

- Read **TAR archives** from disk
- Support **GZipped archives**
- 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
- Scan file list only mode (doesn't read file's content from disk)
- Allows to export content to files
- Optimized for performance and low-memory
- Use stream-first access - file content not stored to memory

## Install

Expand All @@ -23,40 +25,40 @@ composer require jakubboucek/tar-stream-reader

Read files from an archive:
```php
foreach (ArchiveReader::read('example.tar') as $filename => $fileInfo) {
echo "File {$filename} is {$fileInfo->getSize()} bytes size, content of file:\n";
echo $fileInfo->getContent() . "\n\n";
}
```
use JakubBoucek\Tar;

Only scan files from an archive:
```php
foreach (ArchiveReader::scan('example.tar') as $filename => $fileInfo) {
echo "File {$filename} is {$fileInfo->getSize()} bytes size.\n";
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";
}
```
Scan mode is skipping contents od files in Archive. It's faster and less memory consume than read mode.

Define type of archive:
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:
```php
foreach (ArchiveReader::scan('example.tgz') as $filename => $fileInfo) {
echo "File {$filename} is {$fileInfo->getSize()} bytes size.\n";
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 recognize right type of Archive when using classic filename extension (`.tar`, `.tgz`, `.tar.gz`), but you can
set archive type manually by second parameter `ArchiveReader::TYPE_GZ`:

Package allows to process any type of stream, use `StreamReader` instead of `FileReader`:
```php
foreach (ArchiveReader::scan('example.tar+gzip', ArchiveReader::TYPE_GZ) as $filename => $fileInfo) {
echo "File {$filename} is {$fileInfo->getSize()} bytes size.\n";
use JakubBoucek\Tar;

$stream = someBeatifulFuntionToGetStream();

foreach (new Tar\StreamReader($stream) as $file) {
echo "File {$file->getName()} is {$file->getSize()} bytes size.\n";
}
```


## FAQ

### Can I use Package for ZIP, RAR, BZ, … archives?
### Can I use Package for ZIP, RAR, … archives?

No, Package recognize only TAR Archive format, additionaly recognize GZipped Archive.
No, Package recognize only TAR Archive format, additionaly recognize GZipped or BZipped Archive.

### Can I use Package to create/modify Archive?

Expand All @@ -71,8 +73,8 @@ No, TAR Archive is stream-based format, it does not support search, you must alw
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 in read mode limited to available RAM because Content of each file is directly
loaded to variable. For each file content is not available another read method.
- **Size of files in Archive** is teoretically unlimited when use steam-based method to extraxt content
(`toFile()` or `toStream()`), otherwise is size limited with available memory, because is content filled into variable.

## Contributing
Please don't hesitate send Issue or Pull Request.
Expand All @@ -81,4 +83,4 @@ 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.

## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.
The MIT License (MIT). Please see [License File](LICENSE) for more information.

0 comments on commit 9cd27b1

Please sign in to comment.