mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-12 06:48:41 +00:00
Creating static create functions
This commit is contained in:
parent
ef243a7ee4
commit
6b84376742
|
|
@ -33,6 +33,21 @@ class Directory extends FileAbstract implements Iterator, ArrayAccess
|
||||||
private $filter = '*';
|
private $filter = '*';
|
||||||
private $nodes = [];
|
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 = '*')
|
public function __construct(string $path, string $filter = '*')
|
||||||
{
|
{
|
||||||
$this->filter = $filter;
|
$this->filter = $filter;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,22 @@ namespace phpOMS\System\File;
|
||||||
*/
|
*/
|
||||||
class File extends FileAbstract
|
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)
|
public function __construct(string $path)
|
||||||
{
|
{
|
||||||
parent::__constrct($path);
|
parent::__constrct($path);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user