From 9d4d326d6a9913a253e3c5e65dfd1a00df5afde8 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Thu, 21 Jan 2021 11:03:07 +0100 Subject: [PATCH] Add check for directory existence in MD_STD::mkdir --- MD_STD.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MD_STD.php b/MD_STD.php index 8123bba..5776ecb 100644 --- a/MD_STD.php +++ b/MD_STD.php @@ -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"); }