Add check for directory existence in MD_STD::mkdir
This commit is contained in:
parent
298e2238a8
commit
9d4d326d6a
|
@ -64,6 +64,10 @@ final class MD_STD {
|
||||||
*/
|
*/
|
||||||
public static function mkdir(string $pathname, int $mode = 0775, bool $recursive = false):void {
|
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) {
|
if (\mkdir($pathname, $mode, $recursive) === false) {
|
||||||
throw new Exception("Failed to create directory: $pathname");
|
throw new Exception("Failed to create directory: $pathname");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user