From cc0e737182bf4f5be5d730f56b02d5e95a9368ad Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 19 Dec 2016 19:41:13 +0100 Subject: [PATCH] File/directory create permission test --- System/File/Local/Directory.php | 4 ++++ System/File/Local/File.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index e2a66c13d..a2084921c 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -289,6 +289,10 @@ class Directory extends FileAbstract implements DirectoryInterface public static function create(string $path, string $permission = '0644', bool $recursive = false) : bool { if (!file_exists($path)) { + if(!is_writable($path)) { + return false; + } + mkdir($path, $permission, $recursive); return true; diff --git a/System/File/Local/File.php b/System/File/Local/File.php index b4579427a..b97430a6e 100644 --- a/System/File/Local/File.php +++ b/System/File/Local/File.php @@ -315,6 +315,10 @@ class File extends FileAbstract implements FileInterface Directory::create(dirname($path), '0644', true); } + if(!is_writable($path)) { + return false; + } + touch($path); return true;