判断文件流是否可读

@return bool
964890
public function isReadable(): bool
    {
        if ($this->readable === null) {
            $this->readable = false;
            if ($this->isAttached() === true) {
                $meta = $this->getMetadata();
                foreach (self::$modes['readable'] as $mode) {
                    if (strpos($meta['mode'], $mode) === 0) {
                        $this->readable = true;
                        break;
                    }
                }
            }
        }

        return $this->readable;
    }
1212383
public static function find()
    {
      $files = scandir(self::$logger_opts['path']);

      $current = new \DateTime();
      $current->setTimestamp(time());
      $term = __DEFAULT_LOG_PREFIX__ . $current->format("Y-M-D");

      foreach ($files as $f) {
        $matches = array();
        preg_match("/^$term.*$/", $f, $matches);

        if (sizeof($matches) > 0) {
          return $f;
        }
      }


      return FALSE;
    }
156485
public function save()
	{
		$result=true;
		foreach($this->files as $file)
		{
			if($this->confirmed($file))
				$result=$file->save() && $result;
		}
		return $result;
	}
370726
public function open(): bool
    {
        $path = $this->getOptionOrDefault('path');
        if (is_resource($path)) {
            $this->resource = $path;
            return true;
        }

        $context = $this->getOptionOrDefault('context');
        if (is_resource($context)) {
            $this->resource = @fopen($path, 'ab', false, $context);
        } else {
            $this->resource = @fopen($path, 'ab');
        }

        return is_resource($this->resource);
    }
142505
public function accept()
	{
		if( $this->isDot() )
			return FALSE;

		$isDir	= $this->isDir();
		if( !$this->showFiles && !$isDir )
			return FALSE;

		if( $this->stripDotEntries )
		{
			if( preg_match( "@^\.\w@", $this->getFilename() ) )
				return FALSE;
			$pathName	= str_replace( "\\", "/", "/".$this->getPath() );
			if( preg_match( "@/\.\w@", $pathName ) )
				return FALSE;
		}

		return preg_match( $this->pattern, $this->getFilename() );
	}
41304
public function resolveFileMenu()
    {
        $file_index = [];
        $files = $this->files;
        foreach ($files as $key => $file) {
            // 单页文件不做索引
            if (in_array($file['page_uuid'], $this->single_pages)) {
                continue;
            }
            // 标题索引处理
            $content = $this->fileSys->getContent($file['file_path']);
            $token = array_filter(explode("\n", $content['content']), function ($d){
                if (empty($d)) {
                    return false;
                }
                if (strpos($d, "\n#") === false && strpos($d, '#') !== 0 ) {
                    return false;
                }
                return true;
            });
            if (count($token)>0) {
                foreach ($token as &$value) {
                    $value = preg_replace_callback("|(#{1,6} )|", function($m){
                                return '';
                            }, $value);
                    $value = [
                        'title' => $value,
                        'href'  => '#'.$value,
                    ];
                }
            }
            $index = [
                'title' => $file['title'],
                'href'  => $file['href'],
                'uuid'  => $file['page_uuid'],
                'child' => $token
            ];
            $file_index[$file['page_uuid']] = $index;
        }
        $this->file_index = $file_index;
        // dd($file_index);
    }
507891
public function flush()
    {
        if (! $this->files->isDirectory($this->directory)) {
            return false;
        }

        foreach ($this->files->directories($this->directory) as $directory) {
            if (! $this->files->deleteDirectory($directory)) {
                return false;
            }
        }

        return true;
    }
392247
public function saveLocal()
    {
        $file = file_get_contents($this->fileField);
        $this->oriName = basename($this->fileField);
        $this->fileSize = strlen($file);
        $this->fileType = $this->getExtension();
        $this->fullName = $this->getFullName();
        $this->filePath = $this->getFilePath();
        $this->fileName = $this->getFileName();
        $dirName = dirname($this->filePath);

        if (!is_dir($dirName)) {//递归创建保存目录
            FileHelper::createDirectory($dirName, $this->dirMode, true);
        }
        //检查文件大小是否超出限制
        if (!$this->checkSize()) {
            $this->stateInfo = Yii::t('attachment', 'The file size exceeds the site limit.');
            return false;
        }

        //移动文件
        if (!(file_put_contents($this->filePath, $file) && file_exists($this->filePath))) { //移动失败
            $this->stateInfo = Yii::t('attachment', 'An error occurred while saving the file.');
            return false;
        } else { //移动成功
            @unlink($this->fileField);
            $this->saveModel();
            $this->stateInfo = 'SUCCESS';
            return true;
        }
    }
1037377
public function getFilePath() {

		if( isset( $this->url ) ) {

			return Yii::$app->fileManager->uploadDir . '/' . $this->url;
		}

		return false;
	}
1191342
public function toString()
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        return file_get_contents($this->getTmpFile()->getFileName());
    }
1305195
public function all()
	{
		$this->copy();

		$this->read();

		$this->write();

		$this->setSeeded(count($this->getFiles()));

		return true;
	}
192857
public function hasData()
    {
        if ( count( $this->files ) >= 1 )
        {
            if ( $this->files[0] === 'php://stdin' || filesize( $this->files[0] ) > 0 )
            {
                return true;
            }
        }
        return false;
    }
162917
public function read()
    {

        // if file is readable
        if ($this->readable !== true) return false;

        if (!empty($this->fp) && is_resource($this->fp)) fclose($this->fp);

        $this->open_fp('r');

        if (filesize($this->file) == 0) return false;
        $this->lock(LOCK_SH);

        $content = (string)fread($this->fp, ($this->size >= 0) ? $this->size : 1);

        $this->lock(LOCK_UN);

        return $content;
    }
1156491
public function validate() {
        if ($this->file->validate() === false) {
            $this->errors = $this->file->getErrors();
            return false;
        }

        return true;
    }
920775
public function accept() : bool
    {
        $current = $this->current();

        if (!$this->includeHidden && $current->getFilename(){0} == '.') {
            return false;
        }

        if ($this->fileExtensions && $current->isFile() && !in_array($current->getExtension(), $this->fileExtensions)) {
            return false;
        }
        return true;
    }
739007
public function isDir(): bool
    {
        if ($this->caching == false) {
            return is_dir($this->getAbsoluteFilePath());
        }

        if ($this->isDir == null) {
            $this->isDir = is_dir($this->getAbsoluteFilePath());
        }

        return $this->isDir;
    }
482650
public function isValid() {
		
		$params = $this -> getParameters();
		$file 	= $this -> getFile();
		$info 	= (object) pathinfo($file['name']);
		$params = array_map(function($value) {

			if(false === is_string($value)) {
				return trigger_error(sprintf('Extension passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR);
			}

			return ltrim(strtolower($value), '.');
		}, $params);

		if(true === isset($info -> extension) && false === in_array($info -> extension, $params)) {
			return true;
		}

		return false;
	}