Add wrapper around mkdir, that throws an exception on errors
This commit is contained in:
parent
2b4abf6338
commit
d28c245a1a
21
MD_STD.php
21
MD_STD.php
|
@ -49,6 +49,27 @@ final class MD_STD {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper around mkdir, that throws an exception, if the folder cannot be
|
||||||
|
* created.
|
||||||
|
*
|
||||||
|
* @see https://www.php.net/manual/en/function.mkdir.php
|
||||||
|
*
|
||||||
|
* @param string $pathname The directory path.
|
||||||
|
* @param integer $mode Permissions.
|
||||||
|
* @param boolean $recursive Allows the creation of nested directories
|
||||||
|
* specified in the pathname.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false) {
|
||||||
|
|
||||||
|
if (\mkdir($pathname, $mode, $recursive) === false) {
|
||||||
|
throw new Exception("Failed to create directory: $pathname");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets contents of a folder.
|
* Gets contents of a folder.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user