/** * @param Path $Path * @param int $mode * @throws \Exception */ public final function __construct(Path $Path, int $mode = self::AM_DEFAULT) { if ($Path->isFile()) { throw new \Exception('Path "' . $Path->toString() . '" is a file!'); } if ($Path->isLink()) { throw new \Exception('Path "' . $Path->toString() . '" is a link!'); } if (!$Path->isExists() && in_array($mode, [self::AM_PUBLIC, self::AM_INHERIT])) { if (!is_writable($root = Fs::ppath($Path->toString()))) { throw new \Exception('Parent path for "' . $Path->toString() . '" is not exists or not writable!'); } mkdir($Path->toString(), $mode == self::AM_INHERIT ? fileperms($root) : 0777, true); } parent::__construct($Path); }
/** * @param string $path * @return array */ public static function files($path) { return Arr::simplify(array_map(function ($value) { return $value[strlen($value) - 1] == '/' ? [Fs::files($value)] : $value; }, glob(rtrim($path, '/') . '/*', GLOB_NOSORT | GLOB_MARK))); }