1
0
mirror of https://github.com/splitbrain/php-archive.git synced 2025-01-16 21:18:26 +01:00

55 Commits

Author SHA1 Message Date
Mateusz Żółtak
5ff390cbd0 Tar: write performance optimizations
Tar::addData(): pad only the last block of data and write everything
else with just a single writebytes() call and without pack().

Tar::addFile(): move the read chunk size to a class constant.
2024-12-07 10:01:10 +01:00
Mateusz Żółtak
f15ef3a95c Tar::addFile(): use larger read buffer for better performance 2024-12-07 09:51:45 +01:00
Mateusz Żółtak
f931cad249 Tar::readCurrentEntry(): recognize end of file properly 2024-12-06 21:06:24 +01:00
Mateusz Żółtak
6136d0ab63 Tar: allow reading archive content while iterating over archive entries.
So far there was no way to read the data from a file in an archive
without extracting it and extraction of a single file required rereading
of a whole archive. This commit changes the yieldContents() in a way it
does not skip to the next header entry before returning a current header
content. A position of the next header entry is remembered instead and
rewinded to only at the next next() call on the generator. This allows
to read the current entry content until the next() call. For that the
Tar::readCurrentEntry() method was added.
2024-12-06 20:15:23 +01:00
Mateusz Żółtak
3e515824bf Tar: add support for large and negative numbers
In 2001 the GNU tar introduced support for large and negative numbers
(https://www.gnu.org/software/tar/manual/html_node/Extensions.html#Extensions)

This is required to handle files bigger than 8G.
2024-12-06 18:23:51 +01:00
Andreas Gohr
d274e5190b Merge branch 'pr/26' into yield
* pr/26:
  Whoops, fixed wrong variable name.
  Added yieldContents() to keep contents() backward compatibility.
  Use yield in contents() instead of returning a single array with all results.
2022-03-23 10:21:55 +01:00
Andreas Gohr
dc0b5cdd89 moved constant definition to top 2022-03-23 10:13:31 +01:00
Andreas Gohr
1ad16c470b fix PHP <7.3 compatibility
trailing commas not allowed
2022-03-23 10:08:31 +01:00
Mihail Feraru
5a132129e9 Incremental block by block compression for ZIP 2022-03-22 13:15:54 +02:00
mreiden
57a0458d09
Avoid a file exists error instead of supressing it
Suppressing the mkdir error causes a lot of noise in symfony dev logs if there are multiple files in a subdirectory of the tar file. Skip trying to create the subdirectory if it already exists.
2021-08-05 21:09:15 -05:00
Erwin Derksen
c6310630e3 Issue #29 2021-02-22 16:28:49 +01:00
Andreas Gohr
d4cf2d9a2d renamed FileInfo::match() to FileInfo::matchExpression()
In PHP8, `match` is a reserved keyword. In preparation this renames the
method. A fallback via __call() is provided which will trigger a
E_USER_NOTICE.
2020-10-13 14:41:15 +02:00
Michael Loßin
47f6079a42 Fix grammar 2020-08-15 22:50:39 +02:00
jgmdev
0240457f85 Whoops, fixed wrong variable name. 2020-02-19 22:26:08 -04:00
jgmdev
b87b8b736c Added yieldContents() to keep contents() backward compatibility. 2020-02-19 22:13:36 -04:00
jgmdev
0ce9d27ae5 Use yield in contents() instead of returning a single array with all results. 2018-12-24 11:23:04 -04:00
Andreas Gohr
10d8901357 supress chmod and touch warnings
On some file systems these commands will fail. It's unclear what systems
those are, I can reproduce it for touch() on my android phone (but not
on my tablet).

Instead of littering the output with potentially thousands of warnings
we supress them here. Ideally we should probably do something with them,
but I don't know what.

Maybe a strict setting that turns them into exceptions, would work? PRs
welcome.
2018-09-09 14:13:53 +02:00
Andreas Gohr
cabfd12a40 extracted exceptions into their own files
required for PSR-2
2018-06-12 22:09:13 +02:00
Andreas Gohr
0feb2c8107 clean up doc blocks and minor code smell 2018-06-12 22:04:45 +02:00
Andreas Gohr
3b5207aab3 added callback mechanism to show progress during ops 2018-06-12 22:04:17 +02:00
Andreas Gohr
e3a27bdc49 throw ArchiveIllegalCompressionException on bad compression level 2018-06-12 21:50:31 +02:00
Andreas Gohr
a46f3aaeb9 check for broken iconv setup 2018-05-01 10:03:56 +02:00
peter279k
ef1985eead tests enhancement 2018-02-04 19:01:02 +08:00
Owen
ed78f7db29 Fix gzip issue #20 2017-06-10 12:13:03 +08:00
Andreas Gohr
6b1c1746fa Throw an exception when a file changes during reading
see discussion at #17
2017-03-19 10:10:53 +01:00
Andreas Gohr
735029407f fixed that iconv workaround
had a little logic error there - need to preserve the original string to
retry the encoding a second time
2017-03-03 15:44:46 +01:00
Andreas Gohr
aa9ae83c80 fix filesize calculation in GNU long link tar files
also fixes a warning on PHP 7.1
2017-03-03 15:24:37 +01:00
Andreas Gohr
516553390d work around an iconv bug in older PHP versions 2017-03-03 14:52:56 +01:00
Andreas Gohr
3933fc63c6 ignore utf-8 chars that don't fit into CP437 2017-03-03 13:51:59 +01:00
Andreas Gohr
a72a6e56e1 properly encode UTF-8 filenames in zip files #14
Uses the Info-ZIP Unicode Path Extra Field 0x7075
2017-03-03 13:46:31 +01:00
Andreas Gohr
6606edd9ee some improvements on non 7bit string handling #14
This should read at least some zip files with umlauts and stuff better
2017-03-03 12:45:44 +01:00
Andreas Gohr
2e7533b384 always store directories with file size 0. fixes #15 2017-03-03 10:22:10 +01:00
Andreas Gohr
c2490eaadc correctly skip in bzip streams. closes #9 2015-08-12 15:21:54 +02:00
Andreas Gohr
17dab7eec0 ignore null block headers 2015-08-12 12:33:07 +02:00
Andreas Gohr
2188e3f180 fixed size add in Fileinfo::frompath. closes #9 2015-08-12 12:07:51 +02:00
Andreas Gohr
1c69ad040b throw proper exceptions when tar headers can't be parsed 2015-08-12 11:58:17 +02:00
Andreas Gohr
1ae8687e13 Merge branch 'master' into magicbytes
* master:
  added compression example to README
  fixed various calls in the tests
  fixed compression setting on saving inmemory tars
2015-08-12 11:46:46 +02:00
Andreas Gohr
091fac973f fixed various calls in the tests 2015-08-12 11:44:24 +02:00
Andreas Gohr
04f6863f6b fixed compression setting on saving inmemory tars 2015-08-12 11:31:32 +02:00
Andreas Gohr
5e7d32a4f4 use magic bytes to determine compression type 2015-08-12 11:30:10 +02:00
Andreas Gohr
a8881f4e07 correctly remove temporary files when uncompressing ZIPs 2015-07-24 13:29:49 +02:00
Andreas Gohr
89b4cba038 refactored time conversion into it's own method
thanks @furun
2015-06-30 21:12:21 +02:00
Andreas Gohr
a8d442a7cf refactored end of central directory writing. closes #7
turns out there was a stupid copy'n'paste bug that saved the offset of
the central directory wrong
2015-06-30 20:33:05 +02:00
Andreas Gohr
a9d0fb1d74 renamed internal methods to be less confusing 2015-06-30 20:31:55 +02:00
Andreas Gohr
b18e5befd4 correct documentation url 2015-06-30 20:30:55 +02:00
Andreas Gohr
debbe7588c refactored zip header creation. closes #3
This moves the creation of the central and local file headers to their
own methods and makes it easier to follow along the specs.

The writing of the unneeded Data Descriptor was removed.
2015-06-29 21:21:35 +02:00
Andreas Gohr
a0fbfc2f85 fixed inheritence for Zip class
made the setCompression() function behave the same in both classes
2015-02-25 21:15:02 +01:00
Andreas Gohr
0bb99824e2 added license and readme 2015-02-20 15:38:09 +01:00
Andreas Gohr
c948130add zip tests run through as well 2015-02-20 15:07:06 +01:00
Andreas Gohr
3f0d6cf396 tests for Tar are running again 2015-02-20 14:46:22 +01:00