tests pass

master
Guillermo Dev 7 years ago
parent 10715899a0
commit 79a60f13b2

@ -13,30 +13,29 @@ class FileSystem
return true; return true;
} }
$notExistsPart = false;
$parts = explode('/', $path); $parts = explode('/', $path);
if ($file) {
$fileName = array_pop($parts);
}
$partsCount = count($parts); $partsCount = count($parts);
$buildPath = ''; $buildPath = '';
for ($i=0; $i<$partsCount; $i++) { for ($i=0; $i<$partsCount; $i++) {
$part = $parts[$i]; $part = $parts[$i];
if (!file_exists($buildPath . "/$part")) { if (!file_exists($buildPath . "/$part")) {
if (!is_writable($builPath)) { if (!is_writable($buildPath)) {
if ($throw) { if ($throw) {
throw new Exception("Attempting to create : $path, but $buildPath is not writeable."); throw new Exception("Attempting to create : $path, but $buildPath is not writeable.");
} }
return false; return false;
} }
$notExistsPart = true;
break; break;
} }
$buildPath .= "/$part"; $buildPath .= "/$part";
} }
if ($file) {
$fileName = array_pop($parts);
}
$dirPath = implode('/', $parts); $dirPath = implode('/', $parts);
mkdir($dirPath, 0777, true); if (!file_exists($dirPath)) {
mkdir($dirPath, 0777, true);
}
if ($file) { if ($file) {
touch("$dirPath/$fileName"); touch("$dirPath/$fileName");
} }

Loading…
Cancel
Save