preservePharFilePermissions.php
Table of Contents
Functions
- preservePharFilePermissions() : void
- Preserves file permissions from a Phar archive to the extracted files.
Functions
preservePharFilePermissions()
Preserves file permissions from a Phar archive to the extracted files.
preservePharFilePermissions(PharData $phar, string $outputPath) : void
This function iterates over the contents of a PharData archive and applies
the original file permissions (as stored in the archive) to the corresponding
extracted files in the specified output directory.
This is especially useful when extracting .tar or .tar.gz archives where
file modes (e.g., executable bits) should be retained.
If a file's permissions cannot be set, the function logs a warning using error_log().
Parameters
- $phar : PharData
-
The PharData archive instance.
- $outputPath : string
-
The absolute path to the directory where files were extracted.