diff --git a/MD_STD.php b/MD_STD.php index 8fa0ae8..915d9bb 100644 --- a/MD_STD.php +++ b/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. *