Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ZipStreamWriter to stream-write zip archives on PHP 7.2+ #103

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/phpunit-tests-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
with:
php-version: '${{ inputs.php }}'
tools: phpunit-polyfills
extensions: zip

- name: Install Composer dependencies
uses: ramsey/composer-install@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpunit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php: [ '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]

with:
os: ${{ matrix.os }}
Expand Down
14 changes: 11 additions & 3 deletions src/WordPress/Zip/ZipCentralDirectoryEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class ZipCentralDirectoryEntry {

const HEADER_SIZE = 46;

public $isDirectory;
public $firstByteAt;
public $versionCreated;
Expand All @@ -18,7 +20,6 @@ class ZipCentralDirectoryEntry {
public $diskNumber;
public $internalAttributes;
public $externalAttributes;
public $lastByteAt;
public $path;
public $extra;
public $fileComment;
Expand All @@ -37,15 +38,13 @@ public function __construct(
int $internalAttributes,
int $externalAttributes,
int $firstByteAt,
int $lastByteAt,
string $path,
string $extra,
string $fileComment
) {
$this->fileComment = $fileComment;
$this->extra = $extra;
$this->path = $path;
$this->lastByteAt = $lastByteAt;
$this->externalAttributes = $externalAttributes;
$this->internalAttributes = $internalAttributes;
$this->diskNumber = $diskNumber;
Expand All @@ -65,4 +64,13 @@ public function __construct(
public function isFileEntry() {
return false;
}

public function size() {
return (
self::HEADER_SIZE +
strlen($this->path) +
strlen($this->extra) +
strlen($this->fileComment)
);
}
}
19 changes: 18 additions & 1 deletion src/WordPress/Zip/ZipFileEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
namespace WordPress\Zip;

class ZipFileEntry {

/**
* The size of the ZIP file entry header in bytes.
*
* @var int
*/
const HEADER_SIZE = 30;

/**
* @var bool
*/
Expand Down Expand Up @@ -58,7 +66,7 @@ public function __construct(
int $compressionMethod,
int $lastModifiedTime,
int $lastModifiedDate,
int $crc,
$crc,
int $compressedSize,
int $uncompressedSize,
string $path,
Expand All @@ -82,4 +90,13 @@ public function __construct(
public function isFileEntry() {
return true;
}

public function size() {
return (
self::HEADER_SIZE +
strlen($this->path) +
strlen($this->extra) +
$this->compressedSize
);
}
}
Loading