Skip to content

ZipEdit

ZipEdit class allows to edit zip files on the fly and stream them afterwards

  • Full name: \SebLucas\EPubMeta\Tools\ZipEdit

Constants

Constant Visibility Type Value
DOWNLOAD public 1
NOHEADER public 4
FILE public 8
STRING public 32
MIME_TYPE public 'application/epub+zip'

Properties

mZip

private \ZipArchive|null $mZip

mEntries

private array<string,mixed>|null $mEntries

mChanges

private array<string,mixed> $mChanges

mFileName

private string|null $mFileName

mSaveMe

private bool $mSaveMe

Methods

__construct

public __construct(): mixed

__destruct

Destructor

public __destruct(): mixed

Open

Open a zip file and read it's entries

public Open(string $inFileName, int|null $inFlags): bool

Parameters:

Parameter Type Description
$inFileName string
$inFlags int|null

Return Value:

True if zip file has been correctly opended, else false


FileExists

Check if a file exist in the zip entries

public FileExists(string $inFileName): bool

Parameters:

Parameter Type Description
$inFileName string File to search

Return Value:

True if the file exist, else false


FileRead

Read the content of a file in the zip entries

public FileRead(string $inFileName): mixed

Parameters:

Parameter Type Description
$inFileName string File to search

Return Value:

File content the file exist, else false


FileStream

Get a file handler to a file in the zip entries (read-only)

public FileStream(string $inFileName): resource|bool

Parameters:

Parameter Type Description
$inFileName string File to search

Return Value:

File handler if the file exist, else false


FileAdd

Summary of FileAdd

public FileAdd(string $inFileName, mixed $inData): bool

Parameters:

Parameter Type Description
$inFileName string
$inData mixed

FileAddPath

Summary of FileAddPath

public FileAddPath(string $inFileName, string $inFilePath): bool

Parameters:

Parameter Type Description
$inFileName string
$inFilePath string

FileDelete

Summary of FileDelete

public FileDelete(string $inFileName): bool

Parameters:

Parameter Type Description
$inFileName string

FileReplace

Replace the content of a file in the zip entries

public FileReplace(string $inFileName, string|bool $inData): bool

Parameters:

Parameter Type Description
$inFileName string File with content to replace
$inData string|bool Data content to replace, or false to delete

FileGetState

Return the state of the file.

public FileGetState(mixed $inFileName): string|bool

Parameters:

Parameter Type Description
$inFileName mixed

Return Value:

'u'=unchanged, 'm'=modified, 'd'=deleted, 'a'=added, false=unknown


FileCancelModif

Summary of FileCancelModif

public FileCancelModif(string $inFileName, bool $ReplacedAndDeleted = true): int

Parameters:

Parameter Type Description
$inFileName string
$ReplacedAndDeleted bool

Close

Close the zip file

public Close(): void

Throws:


SaveBeforeClose

Summary of SaveBeforeClose

public SaveBeforeClose(): void

Flush

Summary of Flush

public Flush(mixed $render = self::DOWNLOAD, mixed $outFileName = '', mixed $contentType = '', bool $sendHeaders = true, resource|null $outFileStream = null): void

Parameters:

Parameter Type Description
$render mixed
$outFileName mixed
$contentType mixed
$sendHeaders bool
$outFileStream resource|null

copyTest

Summary of copyTest

public static copyTest(string $inFileName, string $outFileName): void
  • This method is static.

Parameters:

Parameter Type Description
$inFileName string
$outFileName string


Automatically generated on 2025-03-18