예제 #1
0
파일: Directory.php 프로젝트: eggbe/files
 /**
  * @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);
 }
예제 #2
0
파일: Fs.php 프로젝트: eggbe/helpers
 /**
  * @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)));
 }