Add wrapper around mkdir, that throws an exception on errors

This commit is contained in:
Joshua Ramon Enslin 2020-12-21 14:50:28 +01:00
parent 2b4abf6338
commit d28c245a1a
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -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.
*