Add check for directory existence in MD_STD::mkdir

This commit is contained in:
Joshua Ramon Enslin 2021-01-21 11:03:07 +01:00
parent 298e2238a8
commit 9d4d326d6a
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -64,6 +64,10 @@ final class MD_STD {
*/
public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false):void {
// One reason, to throw an error, is that the folder already exists.
if (\is_dir($pathname)) {
return;
}
if (\mkdir($pathname, $mode, $recursive) === false) {
throw new Exception("Failed to create directory: $pathname");
}