From 79a60f13b2aef0a7eb9cec5707a22f2d87a3d9c0 Mon Sep 17 00:00:00 2001 From: Guillermo Dev Date: Sun, 21 Oct 2018 23:02:10 +0200 Subject: [PATCH] tests pass --- src/Utils/FileSystem/FileSystem.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Utils/FileSystem/FileSystem.php b/src/Utils/FileSystem/FileSystem.php index 2abce02..8a39da6 100644 --- a/src/Utils/FileSystem/FileSystem.php +++ b/src/Utils/FileSystem/FileSystem.php @@ -13,30 +13,29 @@ class FileSystem return true; } - $notExistsPart = false; $parts = explode('/', $path); + if ($file) { + $fileName = array_pop($parts); + } $partsCount = count($parts); $buildPath = ''; for ($i=0; $i<$partsCount; $i++) { $part = $parts[$i]; if (!file_exists($buildPath . "/$part")) { - if (!is_writable($builPath)) { + if (!is_writable($buildPath)) { if ($throw) { throw new Exception("Attempting to create : $path, but $buildPath is not writeable."); } return false; } - $notExistsPart = true; break; } $buildPath .= "/$part"; } - - if ($file) { - $fileName = array_pop($parts); - } $dirPath = implode('/', $parts); - mkdir($dirPath, 0777, true); + if (!file_exists($dirPath)) { + mkdir($dirPath, 0777, true); + } if ($file) { touch("$dirPath/$fileName"); }