Oihana PHP

assertDirectory.php

Table of Contents

Functions

assertDirectory()  : void
Asserts that a directory exists and is accessible, optionally checking readability and writability.

Functions

assertDirectory()

Asserts that a directory exists and is accessible, optionally checking readability and writability.

assertDirectory(string|null $path[, bool $isReadable = true ][, bool $isWritable = false ][, int|null $expectedPermissions = null ]) : void
Parameters
$path : string|null

The path of the directory to check.

$isReadable : bool = true

Whether to assert that the directory is readable. Default: true.

$isWritable : bool = false

Whether to assert that the directory is writable. Default: false.

$expectedPermissions : int|null = null

Optional permission mask (e.g., 0755).

Tags
throws
DirectoryException

If the path is null, empty, not a directory, or fails accessibility checks.

example
try
{
    $directoryPath = '/chemin/vers/le/repertoire' ;

    assertDirectory( $directoryPath , true , true , 0755 ) ;

    echo "The directory is accessible with the good permissions.\n";
}
catch ( DirectoryException $e )
{
    echo "Error: " . $e->getMessage() . PHP_EOL ;
}
author

Marc Alcaraz (ekameleon)

since
1.0.0

        
On this page

Search results