gemorroj / archive7z Goto Github PK
View Code? Open in Web Editor NEWThis library provides handling of 7z files in PHP
License: GNU Lesser General Public License v3.0
This library provides handling of 7z files in PHP
License: GNU Lesser General Public License v3.0
To unify the directory separators for different file systems.
For example:
$obj = new Archive7z('test.7z');
$obj->getEntry('test/test.txt'); // must be equivalent
$obj->getEntry('test\\test.txt'); // must be equivalent
It is possible to check the encoding via mb_detect_encoding
...
Or at least UTF-8
Hi, thanks for very nice, useful package.
I installed p7zip from OPKG,so the Binary of 7-zip is in /opt/bin/7za, the Archive7z can not find Binary
How can I fix it ? Thanks.
Feature request: treat tar.gz
/tgz
archive as a tar
archive with compression, not as an archive compressed to gz
file.
Right now it treats UnifiedArchive.tar.gz
like
File name | Size | Date
--------------------------------------------------------------------------------
UnifiedArchive.tar | 0.0g | 01 Jan 1970, 3:01
--------------------------------------------------------------------------------
Total 1 file(s) | 0.0g | 0.0g
My propose is to handle this case.
CLI for this is 7z x -so ../UnifiedArchive.tar.gz | 7z l -si -ttar
.
Detailed information:
https://superuser.com/questions/80019/how-can-i-unzip-a-tar-gz-in-one-step-using-7-zip
Execution of example fails on this line:
echo $obj->getContent('test.txt');
Hello and thank you for this cool tool!
I have a problem with reading contents of divided into parts archives. The command is failing, however showing some contents.
File names are stored as hash values.
Is there a simple solution to, maybe, ignore or fix this type of error without archive modification? The process is failing before I can catch it in an easy way.
Example output:
The command "'/usr/bin/7z' 'l' '/home/www/var/files/DB0/hash/f8/01/7c78e011b8ca53015b' '-slt' '-y' '-p '" failed.
Exit Code: 2(Misuse of shellbuiltins)
Working directory: /home/www
Output:
================
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov :2016-05-21
p7zip Version 16.02 (locale=C,Utf16=off,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz (906E9),ASM,AES-NI)
Scanning the drive for archives:
1 file, 220200960 bytes (210 MiB)
Listing archive: /home/www/var/files/DB0/hash/f8/01/7c78e011b8ca53015b
--
Path = /home/www/var/files/DB0/hash/f8/01/7c78e011b8ca53015b
Type = Rar
ERROR = Missing volume : f801b604de805be59b0b7d61288e3811ef31d6e9e091777c78e011b8ca53015b.r00
Physical Size = 220200960
Characteristics = Volume NewVolName FirstVolume VolCRC
Solid = -
Blocks = 1
Multivolume = +
Volume Index = 0
Volumes = 1
----------
Path = setup_Full.exe
Folder = -
Size = 438531863
Packed Size = 220200861
Modified = 2008-09-09 12:52:34
Created =
Accessed =
Attributes = A
Encrypted = -
Solid = -
Commented = -
Split Before = -
Split After = +
CRC = 1B0C199D
Host OS = Win32
Method = m0:22
Version = 20
Errors: 1
See issue below utilizing this package for extracting files from 7z archives. Would be possible to make to Symfony process timeout configurable as described here?
Hi all!
I have a problem with the Archive7z class. I made a function
public function unzip(string $pathToSource): DirectoryIterator { ... $obj = new Archive7z($pathToSource); $obj->setOutputDirectory($pathToDestination); $obj->extract(); return new DirectoryIterator($pathToDestination); }
which returns a DirectoryIterator with the directory to unpack
files.
Next, I collect information about the unpacked files:
$iterator = $this->zipper->unzip($zipFile->getRealPath()); foreach ($iterator as $unzippedFile) { if (!in_array($unzippedFile->getFilename(), ['.', '..'])) { $encoding = mb_detect_encoding($unzippedFile->getFilename()); // ASCII $fileName = $unzippedFile->getFilename(); // 12_1_?????.txt } }
And on my server, the encoding is defined as ASCII, and in the file names instead of Cyrillic letters
question marks.
In the local environment(Docker), everything is displayed normally. mb_detect_encoding($unzippedFile->getFilename())
returns UTF-8 and the file names are correct.
I also tried to reproduce this error in docker and I managed to do it using the link https://zalinux.ru/?p=5740.
That is, I commented out the en_US.UTF-8 UTF-8 encoding in the PHP container in the /etc/locale.gen file and ran the command
locale-gen. After that, I only had ru_RU.UTF-8 UTF-8 encoding left. And after that the encoding of the unpacked files
also began to be defined as ASCII, not UTF-8, and question marks began to appear instead of Cyrillic characters ?
If we return the en_US.UTF-8 UTF-8 encoding in the container and execute locale-gen, then again everything works fine. Tell,
please, what can I do so that when unpacking files, Cyrillic characters are displayed in the file names, not signs
questions. How to make files unpacked in UTF-8 encoding and not ASCII?
Hello. What do you think about adding a method for performing check that 7z
is available?
when using overwrite mode OVERWRITE_MODE_T (-aot) It is duplicating all files even if there is only one file
Hi. Tried library and faced this issue.
$this->seven_zip = new \Archive7z\Archive7z($filename);
foreach ($this->seven_zip->getEntries() as $entry) {
var_dump($entry->getPackedSize());
}
It returns only first file value. Also, that's value for all array, not for specified file.
string(5) "10584"
string(0) ""
string(0) ""
string(0) ""
string(0) ""
string(0) ""
string(0) ""
string(0) ""
getinfo() on gzip not returning much data, specially physicalSize
[path:Archive7z\Info:private] => /test.tar.gz
[type:Archive7z\Info:private] => gzip
[physicalSize:Archive7z\Info:private] =>
[headersSize:Archive7z\Info:private] => 25
[method:Archive7z\Info:private] =>
[solid:Archive7z\Info:private] =>
[blocks:Archive7z\Info:private] =>
[codePage:Archive7z\Info:private] =>
Hello, what is the problem causing this error?
Binary of 7-zip is not available
root@:~# ls -l /usr/bin/7z
-rwxr-xr-x 1 www root 39 Aug 15 2020 /usr/bin/7z
root@:~# 7z -version
7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,1 CPU AMD EPYC 7601 32-Core Processor (800F12),ASM,AES-NI)
Debian11.6๏ผ php7.4.33
Hi. Sorry for bothering you all, but I need some help with installing Archive7z.
My website runs on a 3rd party web hosting service. I uploaded all the files and it seems to be working fine except for one problem: It can't find the 7zip executable.
In Archive7zTrait.php
, I changed the path specified in $binary7zNix
, because there would be some problems with directory permissions, so I now just need the executable to upload. But I can't find a way to get it. I'm using Windows on my PC and I don't have access to the command line of the Linux server, that is used by the hosting service.
Could somebody please send me the executable, so I can upload it? Or if you think that this won't be enough, can you help me in any other way?
Now addEntry($file, $includeSubFiles = false, $storePath = false)
does not support setting name of file in archive. Do you plan to add functionality to specify in-archive path of file when adding it?
\Archive7z\Archive7z::getAutoCli on OSX returns cliWindows, because PHP_OS contains 'Darwin'
So, I think it will be good to fix it and add support for 7z on Mac (e.g. keka archiver https://github.com/aonez/Keka)
for headers https://github.com/ircmaxell/ffime
Line 72 in 458874c
$timeout
in constructor is set to null
.I think in Archive7z
constructor this parameter should be set to 60
too, allowing to set null
to disable check.
Make at least 2 configuration classes - for extract and for compress.
For few archive types, CRC is not parsed from 7z l
, so it is empty, so it fails with Exception
Fatal error: Uncaught TypeError: Archive7z\Entry::getCrc(): Return value must be of type string, null returned in /app/vendor/gemorroj/archive7z/src/Entry.php:240
Stack trace:
#0 /app/src/Drivers/SevenZip.php(217): Archive7z\Entry->getCrc()
#1 /app/src/UnifiedArchive.php(284): wapmorgan\UnifiedArchive\Drivers\SevenZip->getFileData('doc')
#2 /app/src/Commands/TableCommand.php(66): wapmorgan\UnifiedArchive\UnifiedArchive->getFileData('doc')
I found that crc is present for ZIP/TAR.GZ, and not present for TAR
need replace PrecessBuilder
to Process
Fatal error: Call to undefined method Archive7z\Entry::getName()
Replace custom code to execute 7z to SymfonyProcess
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.