tarFileInfo.php
Table of Contents
Functions
- tarFileInfo() : array{is_valid: bool, extension: string, mime_type: string|null, compression: string|null, file_count: int|null, total_size: int|null}
- Retrieves detailed information about a tar archive file.
Functions
tarFileInfo()
Retrieves detailed information about a tar archive file.
tarFileInfo(string $filePath[, bool $strictMode = false ]) : array{is_valid: bool, extension: string, mime_type: string|null, compression: string|null, file_count: int|null, total_size: int|null}
This function inspects the given tar file to determine its validity, compression type, MIME type, number of contained files, and total size of the contents.
It uses the PharData class to count files and calculate total size when the tar is valid.
Parameters
- $filePath : string
-
Absolute path to the tar archive file to inspect.
- $strictMode : bool = false
-
When true, enables strict validation of the tar file structure via assertTar(). Default is false for a more lenient check.
Tags
Return values
array{is_valid: bool, extension: string, mime_type: string|null, compression: string|null, file_count: int|null, total_size: int|null} —Returns an associative array with:
- isValid: Whether the tar file is valid according to assertTar().
- extension: File extension (lowercase) extracted from the path.
- mimeType: MIME type detected via
finfo
. - compression: Compression type detected (gzip, bzip2, or none).
- fileCount: Number of files inside the tar (if valid), otherwise null.
- totalSize: Sum of sizes (in bytes) of all files inside (if valid), otherwise null.