Skip to content

Commit

Permalink
Merge branch 'trunk' into new-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
reimic authored Jun 7, 2024
2 parents 827076f + f9fcb58 commit c415502
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 4 deletions.
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

0 comments on commit c415502

Please sign in to comment.