File/directory create permission test

This commit is contained in:
Dennis Eichhorn 2016-12-19 19:41:13 +01:00
parent 111494c1cc
commit cc0e737182
2 changed files with 8 additions and 0 deletions

View File

@ -289,6 +289,10 @@ class Directory extends FileAbstract implements DirectoryInterface
public static function create(string $path, string $permission = '0644', bool $recursive = false) : bool public static function create(string $path, string $permission = '0644', bool $recursive = false) : bool
{ {
if (!file_exists($path)) { if (!file_exists($path)) {
if(!is_writable($path)) {
return false;
}
mkdir($path, $permission, $recursive); mkdir($path, $permission, $recursive);
return true; return true;

View File

@ -315,6 +315,10 @@ class File extends FileAbstract implements FileInterface
Directory::create(dirname($path), '0644', true); Directory::create(dirname($path), '0644', true);
} }
if(!is_writable($path)) {
return false;
}
touch($path); touch($path);
return true; return true;