diff --git a/System/File/Directory.php b/System/File/Directory.php index d581bbe27..98296a26e 100644 --- a/System/File/Directory.php +++ b/System/File/Directory.php @@ -33,6 +33,21 @@ class Directory extends FileAbstract implements Iterator, ArrayAccess private $filter = '*'; private $nodes = []; + public static create(string $path, $permission = 0644) : bool + { + if (!file_exists($path)) { + if(is_writable($path)) { + mkdir($path, $permission, true); + + return true; + } else { + throw new PathException($path); + } + } + + return false; + } + public function __construct(string $path, string $filter = '*') { $this->filter = $filter; @@ -112,7 +127,7 @@ class Directory extends FileAbstract implements Iterator, ArrayAccess { return next($this->node); } - + public function valid() { $key = key($this->node); diff --git a/System/File/File.php b/System/File/File.php index ca17ee4de..8ef920bcc 100644 --- a/System/File/File.php +++ b/System/File/File.php @@ -30,6 +30,22 @@ namespace phpOMS\System\File; */ class File extends FileAbstract { + + public static create(string $path) : bool + { + if (!file_exists($path)) { + if(is_writable($path)) { + touch($path); + + return true; + } else { + throw new PathException($path); + } + } + + return false; + } + public function __construct(string $path) { parent::__constrct($path);