手工加载指定的文件
可以是相对路径，也可以是绝对路径
@param string $filePath 文件路径
8144
public function loadFile($filePath) {
        require_once (substr($filePath, 0, 1) != '/' && substr($filePath, 1, 1) != ':')
            ? $this->basePath . DIRECTORY_SEPARATOR . $filePath : $filePath;
    }
567923
public function loadHtmlFile($filePath)
    {
        if (!is_string($filePath)) {
            throw new InvalidArgumentException(__METHOD__ . ' expects parameter 1 to be string.');
        }

        if (!preg_match("/^https?:\/\//i", $filePath) && !file_exists($filePath)) {
            throw new RuntimeException("File $filePath not found");
        }

        try {
            $html = file_get_contents($filePath);
        } catch (\Exception $e) {
            throw new RuntimeException("Could not load file $filePath");
        }

        if ($html === false) {
            throw new RuntimeException("Could not load file $filePath");
        }

        $this->loadHtml($html);

        return $this;
    }
1176884
private function inflate($filePath)
    {
        $currentDirectory = rtrim(dirname($this->currentView), self::DS);
        $currentDirectory .= self::DS;
        if (substr($filePath, -6, 6) != '.phtml') {
            $filePath .= '.phtml';
        }

        $searchPath = realpath($currentDirectory . $filePath);
        if ($searchPath != false && file_exists($searchPath)) {
            $content = @include $searchPath;
            if (!$content) {
                // @codeCoverageIgnoreStart
                $e = new ViewFileNotFoundException('Unable to inflate file "' . $searchPath . '"');
                $e->setAdditionalData('View Path: ', $searchPath);
                throw $e;
                // @codeCoverageIgnoreEnd
            }
            return;
        }

        // @codeCoverageIgnoreStart
        $e = new ViewFileNotFoundException('Invalid view file path, expected: "' . $currentDirectory . $filePath . '"');
        $e->setAdditionalData('View Path Checked: ', $currentDirectory . $filePath);
        throw $e;
        // @codeCoverageIgnoreEnd
    }
1060184
public function addAttachment($filePath, $name = null)
    {
        $this->getMailer()->addAttachment($filePath, empty($name) ? pathinfo($filePath, PATHINFO_BASENAME) : $name);
        
        return $this;
    }
847131
protected function postCopy(
        string $filePath
    ): void {
        $this->fileCreationTransaction::setPathCreated($filePath);
        $this->findAndReplaceHelper->replaceName(
            $this->codeHelper->classy($this->className),
            $filePath,
            FieldGenerator::FIND_ENTITY_FIELD_NAME
        );
        $this->findAndReplaceHelper->findReplace(
            $this->codeHelper->consty(FieldGenerator::FIND_ENTITY_FIELD_NAME),
            $this->codeHelper->consty($this->className),
            $filePath
        );
        $this->codeHelper->tidyNamespacesInFile($filePath);
        $this->setGetterToIsForBools($filePath);
    }
1227174
public static function write(string $filePath, string $content = '')
    {
        //如果存在同样的目录名，则不允许这样的文件名
        if (is_dir($filePath)) {
            throw new \InvalidArgumentException("Invalid file path. Some directory name is same as it.");
        }
        //如果目录不存在，创建目录
        $dir = dirname($filePath);
        if (!Dir::make($dir)) {
            throw new \InvalidArgumentException(
                sprintf("can not make the directory of '%s'", $dir)
            );
        }
        return file_put_contents($filePath, $content, LOCK_EX);
    }
745032
public static function setupFromFile($filePath) {

        $loggers = null;

        require($filePath);

        if (!isset($loggers)) {
            throw new LoggerManagerException('The configuration file [' . $filePath . '] must define a variable $loggers');
        }

        if (!is_array($loggers)) {
            throw new LoggerManagerException('The configuration file [' . $filePath . '] must define a variable $loggers as an array');
        }

        self::setupFromArray($loggers);
    }
244976
public function setFile($filePath = '.gitignore')
    {
        $this->fileContent = array();
        $this->afterLine = null;
        $this->filePath = $filePath;
        $this->checkPermissions();
        $this->parse();
    }
1357150
public function setAvatar($filepath)
    {
        if (! file_exists($filepath)) {
            throw new FileNotFoundException("File does not exist at path {$filepath}.");
        }

        $extension = pathinfo($filepath, PATHINFO_EXTENSION);
        $file      = file_get_contents($filepath);
        $base64    = base64_encode($file);

        $this->attributes['avatarhash'] = "data:image/{$extension};base64,{$base64}";

        return true;
    }
1304631
protected function setPermissions($filePath, $overrideFilePermissions)
	{
		if ($overrideFilePermissions) {
			chmod($filePath, $overrideFilePermissions & ~umask());
		}
		elseif (is_null($overrideFilePermissions)) {
			chmod($filePath, 0666 & ~umask());
		}
	}
29910
protected function addFileToProcessedList(string $filePath)
    {
        $arrFile = explode(DIRECTORY_SEPARATOR, $filePath);
        $fileName = array_pop($arrFile);
        $folder = implode(DIRECTORY_SEPARATOR, $arrFile).DIRECTORY_SEPARATOR;
        
        $tmp = new Update();
        $tmp->name = $fileName;
        $tmp->folder = $folder;
        $tmp->createDate = strftime("%Y-%m-%d %H:%M:%S");
        $tmp->save();
        
        echo "Processed: ".$fileName."\n";
        unset($tmp);
    }
466465
public function setFilePath($filePath)
    {
        $this->filePath = $filePath;
        $this->releaseHandle();
        $this->onFileChanged();

        return $this;
    }
373836
public function attachFile(string $filePath, string $name = null)
    {
        $this->attachedFiles[] = [
          'path' => $filePath,
          'name' => $name
        ];

        return $this;
    }
906985
public function deleteFile($filePath)
    {
        $this->throwIfOperationNotInBaseFolder($filePath);

        if (file_exists($filePath) && is_file($filePath)) {
            unlink($filePath);
        }
    }
1151899
private function replaceDummyInFile($filePath)
    {
        $fileSource = File::get($filePath);
        $fileContent = str_replace(array_keys($this->dummyReplacements), array_values($this->dummyReplacements), $fileSource);
        $writeFile = File::put($filePath, $fileContent);
        if ($writeFile === false) {
            throw new \Exception("Error writing to file " . $filePath);
        }
    }
136674
public function addFiles($filePaths): self
    {
        if (is_string($filePaths)) {
            $filePaths = [$filePaths];
        }

        foreach ($filePaths as $filePath) {
            if (! empty($filePath)) {
                file_put_contents($this->manifestPath, $filePath.PHP_EOL, FILE_APPEND);
            }
        }

        return $this;
    }
1315671
public function addWordsFromTextFile($filePath, $delimiter = "\n")
    {
        $words = explode($delimiter, file_get_contents($filePath));
        $this->addWords($words);
    }