{@inheritDoc}
@throws FileException
335109
public function rm($file)
    {
        $parseFile = $this->parseLastDirectory($file);
        if (! ssh2_sftp_unlink($this->getSFtp(), $parseFile)) {
            throw new FileException('File can not deleted');
        }
        return true;
    }
535461
public function main()
    {
        if ($this->property === '') {
            throw new BuildException('no property specified');
        }
        if ($this->destDir === null) {
            $this->destDir = $this->getProject()->resolveFile('.');
        }
        $fu = new FileUtils;
        $tmpFile = $fu->createTempFile(
            $this->prefix,
            $this->suffix,
            $this->destDir,
            $this->deleteOnExit,
            $this->createFile
        );
        $this->getProject()->setNewProperty($this->property, (string) $tmpFile);
    }
912098
public function deleteAllFiles()
    {
        if ($this->isAbsolute()) {
            if ($this->isDir()) {
                // delete files in the current directory and it's subdirectories
                return $this->deleteFilesAction($this->getPathname(), true);
            } else {
                throw new FileException('Given path is a file and not a directory.');
            }
        } else {
            throw new FileException('Given file path is not a absolute path.');
        }
    }
572076
public function addFile($file)
    {
        if (!is_file($file)) {
            throw new MailException("File not found.", E_USER_ERROR);
        }

        $this->attachement[] = $file;

        return $this;
    }
238538
public function delete() {
		foreach ($this as $file) {
			if (!$file->isDot()) {
				$file->delete();
			}
		}

		if (!@rmdir($this->pathname)) {
			throw new FileException(sprintf('Failed to delete directory "%s"', $this->pathname));
		}
	}
649235
public static void setFileData(final File file, final InputStream fileStream, final String contentType) throws FrameworkException, IOException {

		FileHelper.writeToFile(file, fileStream);
		setFileProperties(file, contentType);
	}
302664
public function filePut($file, $data)
    {
        $file = $this->alias->resolve($file);

        $this->_dirCreate(dirname($file));
        if (file_put_contents($file, $data, LOCK_EX) === false) {
            throw new RuntimeException(['write `:file` file failed: :last_error_message', 'file' => $file]);
        }
    }
56945
private function read($bytes)
    {
        if (false === ($read = @fread($this->handle(), $bytes))) {
            throw FileException::lastError();
        }

        if (($actual = strlen($read)) !== $bytes) {
            throw FileException::create(
                'Only read %d of %d bytes from "%s".',
                $actual,
                $bytes,
                $this->file
            );
        }

        return $read;
    }
859083
public static function open($file)
    {
        if (is_string($file)) {
            $file = new \SplFileInfo($file);
        }
        if (!$file->isFile()) {
            throw new ImageException('image file not exist');
        }
        return new self($file);
    }
737889
protected function moveFile($file, $filePath)
	{
		if (!rename($file, $filePath)) {
            $error = error_get_last();
            throw new Exceptions\FileException(sprintf('Could not move the file "%s" to "%s" (%s)', $file, $filePath, strip_tags($error['message'])));
        }
	}
73989
public function parse($file = null) {
        if ($file !== null) {
            $this->setFile($file);
        }
        if (empty($this->file)) {
            throw new LogicException("Need a file to parse.");
        }

        $simple_parsed = parse_ini_file($this->file, true);
        $inheritance_parsed = $this->parseSections($simple_parsed);
        return $this->parseKeys($inheritance_parsed);
    }
731285
private function fileUpload( \EasySwoole\Http\Message\UploadFile $file ) : void
	{
		$this->file = $file;

		if( $file->getError() ){
			throw new \Exception( $file->getError() );
		}

		$this->mediaType  = $file->getClientMediaType();
		$this->ext        = strtolower( explode( '/', $this->mediaType )[1] );
		$this->originName = $file->getClientFilename();

		if( !in_array( $this->ext, $this->allowFileType ) ){
			throw new \Exception( "不支持该类型" );
		}

		// 生成随机名字
		$this->fileName = Random::randStr( $this->randNameLength );

		// 目标全名
		$target_file_name = "{$this->targetFolder}/{$this->fileName}.{$this->ext}";

		// 移动原图到存放目录
		$move_result = $file->moveTo( $target_file_name );

		// 源文件信息
		$this->originFileInfo = $this->getImageInfoFormatData( $target_file_name );

		if( $move_result == false ){
			throw new \Exception( "移动文件失败" );
		}
	}
247322
public function signUsingFile($file, $password = null)
    {
        if (false === is_file($file)) {
            throw FileException::create(
                'The file "%s" does not exist or is not a file.',
                $file
            );
        }

        if (false === ($key = @file_get_contents($file))) {
            throw FileException::lastError();
        }

        $this->sign($key, $password);
    }
1015201
private function checkFile()
    {
        // check File
        if ($this->file === null
            || strlen($this->file) == 0
        ) {
            throw new BuildException('[FileSize] You must specify an input file.', $this->file);
        }

        if (!is_readable($this->file)) {
            throw new BuildException(
                sprintf(
                    '[FileSize] Input file does not exist or is not readable: %s',
                    $this->file
                )
            );
        }
    }
560473
public function read()
    {
        if (empty($this->filename)) {
            Throw new RepositoryException(sprintf('There is no filename set for %s', __CLASS__));
        }

        if (! file_exists($this->filename)) {
            Throw new RepositoryException(sprintf('Config file $s is does not exists', $this->filename));
        }

        if (! is_readable($this->filename)) {
            Throw new RepositoryException(sprintf('Config file $s is not readable', $this->filename));
        }

        $array = include ($this->filename);
    }
1220378
protected function validateFileName($fileName = null)
    {
        if ($fileName === null) {
            $fileName = $this->fileName;
        }

        $fileName = trim($fileName);

        if (!strlen($fileName)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.file_name_required', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validateExtension($fileName, $this->allowedExtensions, false)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file_extension', [
                    'allowed' => implode(', ', $this->allowedExtensions),
                    'invalid' => pathinfo($fileName, PATHINFO_EXTENSION)
                ])
            ]);
        }

        if (!FileHelper::validatePath($fileName, null)) {
            throw new ValidationException(['fileName' =>
                Lang::get('cms::lang.cms_object.invalid_file', [
                    'name' => $fileName
                ])
            ]);
        }
    }
794980
private function copy(string $source, string $target): int
    {
        if (!@copy($source, $target)) {
            $message = 'Could not copy file.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return $this->stat($target)['size'];
    }