From: Vincent Vanwaelscappel Date: Mon, 13 Sep 2021 17:11:49 +0000 (+0200) Subject: wip #4666 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=625020133b3199d9dacf967225e97deba625a5c5;p=cubist_util.git wip #4666 @0.5 --- diff --git a/src/Files/Files.php b/src/Files/Files.php index 764b07b..1807805 100644 --- a/src/Files/Files.php +++ b/src/Files/Files.php @@ -24,11 +24,16 @@ class Files public static function mkdir($path, $mode = 0777, $recursive = true) { - if (file_exists($path)) { - return; + if (!file_exists($path)) { + try { + if (!mkdir($path, $mode, $recursive) && !is_dir($path)) { + throw new \RuntimeException(sprintf('Directory "%s" was not created', $path)); + } + } catch (\Exception $e) { + throw new \RuntimeException(sprintf('Directory "%s" was not created. %s', $path, $e->getMessage())); + } } - mkdir($path, $mode, $recursive); - return realpath($path); + return realpath($path).'/'; } public static function humanReadableSize($size, $precision = 2) diff --git a/src/Files/VirtualDirectory.php b/src/Files/VirtualDirectory.php index ac312e4..f686fdc 100644 --- a/src/Files/VirtualDirectory.php +++ b/src/Files/VirtualDirectory.php @@ -1,6 +1,7 @@ _directories as $to => $from) { $this->_addDirectory($from, $to); } @@ -73,7 +78,11 @@ class VirtualDirectory $existing[$to] = true; } if (!file_exists($to) || filesize($from) != filesize($to) || filemtime($from) > filemtime($to)) { - copy($from, $to); + try { + copy($from, $to); + } catch (\Exception $e) { + throw new \Exception(sprintf('Failed to copy %s to %s', $from, $to)); + } } }