Giter Club home page Giter Club logo

wapmorgan / unifiedarchive Goto Github PK

View Code? Open in Web Editor NEW
274.0 14.0 20.0 13.74 MB

UnifiedArchive - an archive manager with unified interface for different formats (bundled with cli utility). Supports all formats with basic operations (reading, extracting and creation) and popular formats specific features (compression level, password-protection, comment)

Home Page: http://wapmorgan.github.io/UnifiedArchive/

License: MIT License

PHP 99.57% Dockerfile 0.31% Makefile 0.12%
tar zip rar archives archiving cab iso 7zip gzip bzip2

unifiedarchive's Introduction

UnifiedArchive - an archive manager with unified interface for different formats that works on wide variety of system configuration. It supports all basic operations on widespread formats and some format-specific features for most popular ones (zip, rar, 7z, tar).

Main purpose of this library is to create unified interface for popular archive formats, that works in various system configurations via different drivers, when there is no ability to update system configuration, when code delivered to another system configurations, or when you just want to install libraries and work. It's handy when there's need to support archive types regardless of the system configuration.

Latest Stable Version Total Downloads Daily Downloads License Latest Unstable Version

Tests & Quality: Scrutinizer Code Quality Code Coverage

  1. Functions & Features
  2. How it works
  3. Quick start
  4. Built-in console archive manager
  5. Usage
  6. Drivers & formats
  7. Full API description
  8. Changelog

Functions & Features

UnifiedArchive is aimed to provide all operations on popular archive formats (zip, tar, rar, 7z) by all means and at better performance (depends on your OS/PHP configuration). Also, it allows to work with less popular archive types (with lack of functions).

Main functions:

  • Open an archive with automatic format detection (more 20 formats).
  • List archive content, calculate original size of archive
  • Get details (original size, date of modification) of every archived file. Extract or stream archived file content
  • Extract all archive content. Append an archive with new files or directories. Remove files from archive
  • Create new archives with files/directories on disk and stream from memory
  • Fully implemented PclZip-like interface for archives for all formats. Easy transition from old PclZip.
  • Bundled with cli utility

Specific functions:

How it works

UnifiedArchive uses "drivers", which can be one of types:

  1. PHP Extensions
  2. Utilities + bridge
  3. Pure PHP

By default, UA goes top-down to select first available driver for passed archive. So, PHP Extension driver will be used (if available), then Utilities + bridge driver (if available), and then Pure PHP driver.

There is at least one driver in all three types, which handles zip format, so this format can be fully supported in any OS/PHP configuration:

  1. PHP extensions: zip / phar
  2. Utility + bridge: SevenZip / AlchemyZippy
  3. Pure: NelexaZip / SplitbrainPhpArchive

tar format (with compressed variants) supported by:

  1. PHP extension: phar
  2. Utility + bridge: SevenZip / AlchemyZippy
  3. Pure: TarByPear / SplitbrainPhpArchive

So, there is always one driver that supports popular formats, and you should not remember how to work with this concrete driver (zip/phar/SevenZip/AlchemyZippy/NelexaZip/SplitbrainPhpArchive), interface for them is uniform.

Quick start

Installation and configuration

Install library

composer require wapmorgan/unified-archive
#Check supported formats with installed drivers
./vendor/bin/cam system:formats
#Check supported functions for zip format
./vendor/bin/cam system:format zip

Install new driver

#Read installation instructions from
./vendor/bin/cam system:drivers
#install missing drivers, for example pear/archive_tar
composer require pear/archive_tar
#check out driver functions
./vendor/bin/cam system:formats TarByPear

#if needed, install extensions, cli tools and php libraries
#to enable support of other formats

Usage

use \wapmorgan\UnifiedArchive\UnifiedArchive;
$output_dir = '/var/www/extracted';
# Extraction
$archive = UnifiedArchive::open('archive.zip'); // archive.rar, archive.tar.bz2
if (disk_free_space($output_dir) < $archive->getOriginalSize()) {
    throw new \RuntimeException('No needed space available. Need ' . ($archive->getOriginalSize() - disk_free_space($output_dir)) . ' byte(s) more');
}
$extracted = $archive->extract($output_dir);
echo 'Number of extracted files' . $extracted.PHP_EOL;

# Archiving
UnifiedArchive::create([
    'README.md' => '/default/path/to/README.md',
    '' => '/folder/with/content/',
], 'archive.zip');

Built-in console archive manager

UnifiedArchive is distributed with a unified console program to manipulate archives. It supports all formats and all operations on them that UnifiedArchive does, so it can be used to manipulate archives without other system software. To show help, launch it:

./vendor/bin/cam list # help
./vendor/bin/cam archive:info archive.tar.gz # archive information
./vendor/bin/cam files:list -l archive.tar.gz # files list (or files:table for table)
./vendor/bin/cam archive:extract archive.tar.gz ./OUTPUT/ # extraction all archive
./vendor/bin/cam archive:create --compression=maximum archive2.tar.gz ./OUTPUT/partners # archive creation from files

unifiedarchive's People

Contributors

adriannuta avatar cedric-anne avatar dgame avatar jasonhoule avatar patie avatar wapmorgan avatar wlkns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unifiedarchive's Issues

Extract archive with a folder at his root not working

Describe the bug
When I try to extract an archive created with a folder as source, I got this error back :

Warning: ZipArchive::extractTo(/Users/olivierbossel/data/web/dwarvesforge/thorin/data/extracted/): failed to open stream: Is a directory in /Users/olivierbossel/data/web/dwarvesforge/thorin/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php on line 689

Configration (please complete the following information):

  • OS: OSX
  • Version: 10.13.6

To Reproduce

  1. Zip a folder with an image inside like so:
UnifiedArchive::archiveFiles('my-folder', 'my-archive.zip');
  1. Unzip the created archive like so:
$archiveInstance = UnifiedArchive::open('my-archive.zip');
$archiveInstance->extractFiles('folder-to-extract-to');

Expected behavior
I expect that my archive will be extracted and that I get back a folder structure like so:
| folder-to-extract-to
|--- my-folder
|------ my-image.jpg

Thanks in advance! And thanks for your nice job on this library!
Cheers!

Returns null on rar archives

Describe the bug
Seems like UnifiedArchive can't recognize rar archives when everything is ok with zip ones.

Configration (please complete the following information):

  • MacOS: 10.14.6
  • PHP: 7.4.1
  • Laravel Framework: 5.7.28
  • Version of library: 0.2.0

To Reproduce

  1. Download this rar archive ftp://emexonline.com/megaprice/24H.rar
  2. $archive = UnifiedArchive::open("24H.rar");
  3. null

Expected behavior
A clear and concise description of what you expected to happen.

Roadmap to 1.2.0

  • Ability to set/clear passwords and open archives with passwords
  • Ability to add files from string
  • Ability to iterate over files list

Compress no longer available

Describe the bug
The compress command is no longer available on Debian based systems. It still appears to be available in Unix and BSD systems. In LzwStreamWrapp::checkBinary() there is a check for both compress and uncompress. When attempting to extract a .tar.Z file the extract fails because of the isBinaryAvailable() check but uncompress is in fact still available.

The archive xmlfeed_lic475-2021_09_24.tar.Z could not be extracted. compress and uncompress commands are required

Configration (please complete the following information):

  • OS: Ubuntu 20.04.3
  • Version of library: 1.4.14

To Reproduce
Attempt to extract a LZW compressed .tar.Z file on newer debian systems where compress is not available or installable.

Expected behavior
Perhaps there could be a separate check. If writing to the archive then check for compress? Please take a look at the below. If that works for you then I can submit a pull request

Possible Fix

/**
     * @throws \Exception
     */
    protected static function checkBinary($write = false)
    {
        if (self::$installed === null) {
            if (strncasecmp(PHP_OS, 'win', 3) === 0) {
                self::$installed = false;
            } else {
                self::exec('command -v compress', $output);
                if ($write && empty($output)) {
                    self::$installed = false;
                } else {
                    self::exec('command -v uncompress', $output);
                    if (empty($output)) {
                        self::$installed = false;
                    } else {
                        self::$installed = true;
                    }
                }
            }
        }
    }
/**
     * @param $data
     * @return bool|int
     */
    public function stream_write($data)
    {
        $this->checkBinary(true);
        if (self::$installed === false)
            throw new \Exception('compress and uncompress commands are required');
        $this->writtenBytes += strlen($data);
        if ($this->tmp !== null) {
            $fp = fopen($this->tmp, 'w'.(strpos($this->mode, 'b') !== 0 ? 'b'
                : null));
            fseek($fp, $this->pointer);
            $count = fwrite($fp, $data);
            $this->pointer += $count;
            fclose($fp);

            return $count;
        } else {
            $count = strlen($data);
            $prefix = substr($this->data, 0, $this->pointer);
            $postfix = substr($this->data, ($this->pointer + $count));
            $this->data = $prefix.$data.$postfix;
            $this->pointer += $count;

            return $count;
        }
    }

Some of used packages are abandoned, consider to use something instead

Describe the bug
Package jakub-onderka/php-console-color is abandoned
Package jakub-onderka/php-console-highlighter is abandoned
Package zendframework/zend-diactoros is abandoned

Configration (please complete the following information):
Using version ^0.2.0 for wapmorgan/unified-archive

To Reproduce
run composer require wapmorgan/unified-archive

Using version ^0.2.0 for wapmorgan/unified-archive
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing wapmorgan/unified-archive (0.2.0): Downloading (100%)         
wapmorgan/unified-archive suggests installing ext-rar (RAR support)
wapmorgan/unified-archive suggests installing ext-xz (XZ and TAR.XZ support)
wapmorgan/unified-archive suggests installing pear/archive_tar (another TAR support)
wapmorgan/unified-archive suggests installing bin-ncompress (TAR.Z support)
wapmorgan/unified-archive suggests installing gemorroj/archive7z (7ZIP support)
wapmorgan/unified-archive suggests installing wapmorgan/cab-archive (CAB support)
wapmorgan/unified-archive suggests installing phpclasses/php-iso-file (ISO support)
wapmorgan/unified-archive suggests installing docopt/docopt (Requirement for cam (Console Archive Manager))
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.

Extract RAR file error

I have successfuly extract RAR file with extractFiles() but the error is still been thrown.

Error:
"Could not extract archive: The command "'/usr/bin/7z' 'x' '/var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar' '-aoa' '-o/var/www/project/storage/app/tmp/test' '-y' '-p '" failed.\n\nExit Code: 2(Misuse of shell builtins)\n\nWorking directory: /var/www/project/public\n\nOutput:\n================\n\n7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21\np7zip Version 16.02 (locale=C,Utf16=off,HugeFiles=on,64 bits,1 CPU AMD FX(tm)-6100 Six-Core Processor (600F12),ASM,AES-NI)\n\nScanning the drive for archives:\n1 file, 4359357 bytes (4258 KiB)\n\nExtracting archive: /var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar\n--\nPath = /var/www/project/storage/app/tmp/rUAl2hT4NZjkbqQIMHvmutUNPGNIOhTgzpZAOdNL.rar\nType = Rar5\nPhysical Size = 4359357\nSolid = -\nBlocks = 7\nEncrypted = -\nMultivolume = -\nVolumes = 1\n\n\nSub items Errors: 3\n\nArchives with Errors: 1\n\nSub items Errors: 3\n\n\nError Output:\n================\nERROR: Unsupported Method : jsRar/images_1/testCopy.png\nERROR: Unsupported Method : jsRar/images_1/testCopy2.jpg\nERROR: Unsupported Method : jsRar/images_2/eBa.png\n"

Cannot access phar file entry '/' in archive 'myfile.tgz'

Describe the bug

When trying to extract a .tgz file with UnifiedArchive it reports the following error message:
In Tar.php line 369:
"Cannot access phar file entry '/' in archive 'myfile.tgz'"

Doing the same with CLI commands gunzip myfile.tgz & tar xf myfile.tar works fine.

Configuration

  • OS: linux debian 9.3
  • Version of library: 0.1.2
  • Satisfied Composer dependencies (selection)
    "php": "^7.0",
    "ext-phar": "",
    "ext-zip": "
    ",
    "ext-zlib": "*",
    "pear/archive_tar": "~1.4.3",
    "wapmorgan/unified-archive": "^0.1"

tar -tvf myfile.tar shows this (shortened list):
drwxr-xr-x web/users 0 2019-01-11 02:10 ./
-rw-r--r-- web/users 15254 2019-01-11 02:10 ./myfile.xml

To Reproduce

$archive = UnifiedArchive::open($absoluteArchiveFilePath);
$numberOfFiles = $archive->extractFiles($absoluteTargetDirPath);

Expected behavior

Contents of .tgz file should be extracted to the target directory.

bug on php7.2

hi.
it's me again:-)
Found bug in

protected $files;

Need to declare $files property as array. ( protected $files = array(); )
To replicate bug just rename any jpg-file into zip and try to run this code

$archive = UnifiedArchive::open($archive_filename);
$files = $archive->getFileNames();

inside method getFileNames property $this->files will be null, not array! array_values will show warning
Tested on php7.2.

Best regards:-)

Rar+password "mount archive" produce unreadable file

Describe the bug
when i mount a rar achive with password and provide the correct password in the Archive tab
the mount point is created with the files inside BUT they are unreadable
I assume the rar password decryption is buggy
zip archive password decryption works flawless

Configration (please complete the following information):

  • OS: ubuntu 20.04
  • Version of library:

To Reproduce
Upload a rar file with password
type the password in the archive tab
mount the rar file via context menu

Expected behavior
should decrypt and mount with password given

Problem with deleting .zip file

Throws exectiopn while deleting .zip file
file: "/var/www/project/vendor/wapmorgan/unified-archive/src/Drivers/Zip.php"
message: "No such file"

I don't have this problem when deleting files with .7z extension

UnifiedArchive::open() returns null for .tar.Z files.

Describe the bug
When attempting to open a .tar.z file null is returned.

Configration (please complete the following information):

  • OS: [e.g. linux / windows / osx] Linux
  • Version of library: [e.g. 0.1.0] 0.1.2

To Reproduce
Steps to reproduce the behavior (your code).
Attempt to open a LZW compressed tar file.

Expected behavior
A clear and concise description of what you expected to happen.
Expected a UnifiedArchive instance to be returned.

I have submitted pull request: Fix check for LZW compression #14

Not working in php 5.6

Hi,

I tried to use the package in system running on php 5.6 but got the below error.
Static function wapmorgan\UnifiedArchive\AbstractArchive::open() should not be abstract

UnifiedArchive::open($image_path)

Do you have any idea?

Exclude directories from UnifiedArchive::archiveFiles

Is there a way to exclude folders when creating an archive?

In my data folder I have a logs folder and a temporary folder that I don't necessarily want to back up.

UnifiedArchive::archiveFiles(['Data' => $persistentData], $backupSource);

Extract tar.gz memory exhaustion

Describe the bug

Error:

Allowed memory size of 536870912 bytes exhausted (tried to allocate 512913866 bytes)

The error explodes here: PharData

Configration (please complete the following information):

  • OS: alpine
  • Version of library: latest

To Reproduce

Try to extract a file bigger than you max memory limit

It seems it's loading the entire file in memory, is this expected?

Interesting enough it works when extracting big gzip files

ProcessTimedOutException on large 7Zip archives

Describe the bug
I am hitting the ProcessTimedOutException on large 7Zip archive. This only occurs when processing files towards the end of the archive. For example the timeout is hit on file 28 out of 35.

Configration (please complete the following information):

  • OS: Linux
  • Version 0.1.0

To Reproduce

$archive = UnifiedArchive::open('path/to/large/7zip-archive.7z');
$archive->getFileContent($filename);

Expected behavior
The process timeout should be configurable. I noticed you are using Gemorroj/Archive7z for the this, so I am not sure the best way to handle this. I guess first that package should start supporting the timeout?

[Symfony\Component\Process\Exception\ProcessTimedOutException]
The process "'/usr/bin/7za' 'x' 'largeArchive.7z' '-so' 'output.ext' '-y' '-p '" exceeded the timeout of 60 seconds.


Exception trace:
 Symfony\Component\Process\Process->checkTimeout() at /app/vendor/symfony/process/Process.php:383
 Symfony\Component\Process\Process->wait() at /app/vendor/symfony/process/Process.php:202
 Symfony\Component\Process\Process->run() at /app/vendor/symfony/process/Process.php:222
 Symfony\Component\Process\Process->mustRun() at /app/vendor/gemorroj/archive7z/src/Archive7z.php:408
 Archive7z\Archive7z->getContent() at /app/vendor/gemorroj/archive7z/src/Entry.php:133
 Archive7z\Entry->getContent() at /app/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php:554
 wapmorgan\UnifiedArchive\UnifiedArchive->getFileContent() at /app/app/Console/Commands/Archive.php:173

getComment() throws but should return null instead

Describe the bug

API documents that UnifiedArchive::getComment() should return null when comments are not supported by either the archiver format or the used driver:

https://github.com/wapmorgan/UnifiedArchive/blob/master/docs/API.md#archive-information

However, the method actually throws an UnsupportedOperationException, see

throw new UnsupportedOperationException();

Configration (please complete the following information):
Irrelevant for this issue.

To Reproduce
Run UnifiedArchive::getComment() e.g. on a .tar file.

Expected behavior
The method should return null as per API documentation or the API documentation should state the the method throws. It is of course perfectly fine if the method throws an exception, it is just documented differently.

alchemy/zippy, Member::getLatsModifiedDate() return DateTime, not string

Hi there,

I think I stumbled over a bug here:

$member = $this->getMember($fileName);
return new ArchiveEntry($member->getLocation(), $member->getSize(), $member->getSize(), strtotime($member->getLastModifiedDate()), true);

At least in version 1.0 (the current since 2021) Member::getLastModifiedData() returns DateTime, not a textual representation of the last mtime. Hence strtotime() -- which expects a string -- fails. According to "git blame" this has always be the case(?) which surprises. I'll shortly submit a pull request.

Best

Claus

Rar: getArchiveInformation : skip Directories

Is your feature request related to a problem? Please describe.
For rar archives getArchiveInformation() does not ignore directories as for instance this is done for zip files. This causes troubles in my application (phhoehne/phpCBRServer) where I only need the files

zip:

    public function getArchiveInformation()
    {
        $information = new ArchiveInformation();
        for ($i = 0; $i < $this->zip->numFiles; $i++) {
            $file = $this->zip->statIndex($i);
            // skip directories
            if (in_array(substr($file['name'], -1), ['/', '\\'], true)) {
                continue;
            }
            $information->files[$i] = $file['name'];
            $information->compressedFilesSize += $file['comp_size'];
            $information->uncompressedFilesSize += $file['size'];
        }
        return $information;
    }

rar:

    public function getArchiveInformation()
    {
        $information = new ArchiveInformation();
        foreach ($this->rar->getEntries() as $i => $entry) {
                $information->files[] = $entry->getName();
                $information->compressedFilesSize += $entry->getPackedSize();
                $information->uncompressedFilesSize += $entry->getUnpackedSize();                
        }
        return $information;
    }

Describe the solution you'd like

    public function getArchiveInformation()
    {
        $information = new ArchiveInformation();
        foreach ($this->rar->getEntries() as $i => $entry) {
            if(!$entry->isDirectory()) {
                $information->files[] = $entry->getName();
                $information->compressedFilesSize += $entry->getPackedSize();
                $information->uncompressedFilesSize += $entry->getUnpackedSize();                
            }
        }
        return $information;
    }

Describe alternatives you've considered
I could handle this "application side" but it's somehow insufficient and - as stated before - current implementation is consistent

open($fileName, password: given) broken

The square-brackets at the RHS must vanish:

$abilities[] = [BasicDriver::OPEN_ENCRYPTED];

Otherwise just specifying a password will lead to "array to string conversion" errors. Of course, the work-around is to specify options explicitly. I think this would be a good candidate for a hot-fix release.

Thx for this package!

Unable to extract a ".tar.xz" archive

Describe the bug
When trying to open a tar.xz, the open function return null.

Configration (please complete the following information):

  • OS: linux
  • Version of library: latest, PHP 8

To Reproduce
What I've done :

RUN mkdir -p /tmp/php-ext-xz \
    && git clone https://github.com/codemasher/php-ext-xz.git /tmp/php-ext-xz \
    && docker-php-ext-configure /tmp/php-ext-xz \
    && docker-php-ext-install /tmp/php-ext-xz \
    && rm -r /tmp/php-ext-xz

I'm working inside a docker container but the installation is OK, there is a xz extension loaded.

My problem is when doing $archive = UnifiedArchive::open('archive.tar.xz'); the format found by UnifiedArchive is TAR_LZMA which require extension_loaded('lzma2') to be true in TarByPear.php.

I don't have this extension and can't find anything on Google on how to install it for 1 hour now...

What I find strange is, if I manually change the extension_loaded('lzma2') to extension_loaded('xz') in TarByPear.php line 71, the archive is correctly opened and I can use $archive->extractFiles('/tmp/'); without problem, the archive is decompressed and extracted...

What I my missing, I'm going mad ! ^^

I should add, I tried to change the extension of my archive to

  • .tar -> exception (UnexpectedValueException TarByPhar line 94)
  • .xz -> memory exhaustion (it seems it try to load the whole archive in memory)

Hope it's a simple mistake on my end ! Help !

Error in docs? UnifiedArchive::archiveFiles

When trying to create an archive using the example in the docs, I got an error saying that "archiveFiles" is undefined.

Does not work;
UnifiedArchive::archiveFiles('/var/log', 'Archive.zip');

Works;
UnifiedArchive::archiveNodes('/var/log', 'Archive.zip');

Is this an error in the docs? I am using version 0.0.11.

Extract Not Working

I was trying to extract TAR files and the UnifiedArchive have no problem opening the file, but the extract method always returned false. Is there any way I can debug the issue?

I have tried both with and without installing the Archive_Tar package.

extract tar.bz2, tar.xz, open function return NULL

extract tar.bg2 and tar.xz error.

Call to a member function extractFiles() on null

  • OS: ubuntu16.04
  • Version of library: 0.1.0
  • PHP Version: 7.2.5

try {
$archive = UnifiedArchive::open('/home/hi/a.tar.bz2');
$result = $archive->extractFiles('/home/hi/a');
} catch (\Exception $e) {
info($e->getMessage());
}

rar error massage problem

There is one file shows error like this

An uncaught Exception was encountered
Type: RarException

Message: unRAR internal error: Failed to open /var/www/sub/2020/01/157838650259114.rar: ERAR_BAD_ARCHIVE

Filename: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php

Line Number: 34

Backtrace:

File: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php
Line: 34
Function: open

File: /var/www/vendor/wapmorgan/unified-archive/src/Formats/Rar.php
Line: 24
Function: open

File: /var/www/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php
Line: 257
Function: __construct

File: /var/www/vendor/wapmorgan/unified-archive/src/UnifiedArchive.php
Line: 106
Function: __construct

AND i try everthing to avoid the error , it still there .. i saw the doc said if there is mistake it will return null .. but it's not ..

getResource method

Would it be possible to add a method to get the raw resource? My use case is that i have a bunch of text file in a zip file. I didn't inspect the code of this package but i assume it's using functions like https://secure.php.net/manual/en/function.zip-open.php which give back a resource. Then the resource can be used to pass to file() yes file also takes streams and such. So then i can split my text files into an array of lines. Right now i think the best option would be to use getFileContents (from the API) and then preg_split('/\R/', $str);. But working on resources is just nice for a bunch of things so might be worthwhile adding a method to get the resource, and possibly a method to get the file as an array of lines.

what if i don't want to use pear ?

Hi.
Your code is awesome!

I tried to unpack tar.gz archive but i have no pear library installed. And i do not plan use it in the future.
I suggest you unpack tar.gz with PharData php-class instead. It can to extract tar archives too.

try {
          $phar = new PharData($archive_filename);
          $phar->extractTo($dest_directory, null, true);
} catch (Exception $e) {}

See this check

if ((in_array($ext, array('tar', 'tgz', 'tbz2', 'txz')) || preg_match('~\.tar\.(gz|bz2|xz|Z)$~', $filename)) && class_exists('\Archive_Tar'))

Work with 7zip archive format

Hi, thanks for very nice, useful package.
I try to implement creating achives .7z and .7zip from files, add this extentions too - gemorroj/archive7z, but get the next error:

Could not create archive: Binary of 7-zip is not available

I saw in you docs that need use "Uses system binary 7z to work". I try convert files that need archive to binary but this not help, not good understand how it use.
Can a bit clarify where I made a mistake, or some example how to work with create .7z and .7zip archive?
Thank a lot.

Creating a tar.gz file also creates a .tar file

Describe the bug

I'm creating a tar.gz file with something like:

UnifiedArchive::archiveDirectory($path, 'file.tar.gz');

The result is 2 files gets created: file.tar and file.tar.gz.

I'm manually deleting .tar on my implementation but wanted to check if there is any reason for keeping it, I can open a PR to fix this behavior, just wanted to check first.

Get a list of directories in the archive

I need to be able to unpack an archive with all of the included directories not just the files.
Would it be possible to either get a separate list of empty directories or all the directories found in the archive?

Error with pear/tar requirement

Hi,

Your package looks great, I'm just running into problems installing...

I have no use for tar or do I use pear, I plan to use zip + rar, could you please remove this package from the requirements.

wapmorgan/unified-archive dev-master requires pear/archive_tar dev-master -> no matching package found.

Submitted pull request #2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.