| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\Core\FileReader;
- /**
- * Description of File
- *
- * @author Rafał Ossowski <rafal.os@modulesgarden.com>
- */
- class File
- {
- public static function createFile()
- {
- // next version
- }
- public static function createPaths()
- {
- foreach (func_get_args() as $path)
- {
- if (is_array($path) && isset($path['permission']) && self::createPath($path['full'], $path['permission']) === false)
- {
- $parentPath = explode(DS, $path['full']);
- array_pop($pathFull);
- $parentPath = implode(DS, $parentPath);
- self::setPermission($parentPath);
- self::setUser($path['full'], 'www-data');
- self::createPath($path['full'], $path['permission']);
- }
- elseif (is_array($path) && self::createPath($path['full']) === false)
- {
- $parentPath = explode(DS, $path['full']);
- array_pop($pathFull);
- $parentPath = implode(DS, $parentPath);
- self::setPermission($parentPath);
- self::setUser($path['full'], 'www-data');
- self::createPath($path['full']);
- }
- else
- {
- self::createPath($path);
- }
- }
- }
- public static function createPath($path, $permission = 0777)
- {
- if (!is_string($path) || file_exists($path)) {
- return;
- }
- return mkdir($path, $permission);
- }
- public static function setPermission($file, $permission = 0777)
- {
- return chmod($file, $permission);
- }
- public static function setUser($file, $user)
- {
- return chown($file, $user);
- }
- /**
- * @return PathValidator
- */
- public static function getValidator()
- {
- return new PathValidator();
- }
- }
|