php8.5
Home/ Manual/ rar / rarentry/ RarEntry::isDirectory

RarEntry::isDirectory

PHP function Edit on GitHub ✎

(PECL rar >= 2.0.0)

Test whether an entry represents a directory

Description

RarEntry::isDirectory(): bool

Tests whether the current entry is a directory.

Parameters Parameters

Return Values

Returns true if this entry is a directory and false otherwise.

Notes

This function is only available starting with version 2.0.0, but one can also test whether an entry is a directory by checking the entry attributes, like this (only works for files compressed in RAR for Windows or Unix):

php
<?php
//...
//Open file, get entry and store in variable $e...
//...

$isDirectory = (bool) ((($e->getHostOs() == RAR_HOST_WIN32) && ($e->getAttr() & 0x10)) ||
    (($e->getHostOs() == RAR_HOST_UNIX) && (($e->getAttr() & 0xf000) == 0x4000)));
?>

Source: reference/rar/rarentry/isdirectory.xml · from the official PHP manual (php/doc-en)