Makes a File out of an existing file.

@param string $filename

@return File

@throws FileNotFoundException
961320
public function open($filename)
    {
        if (!$this->exists($filename) || false === $content = file_get_contents($filename)) {
            throw new FileNotFoundException($filename);
        }

        return $this->makeFile($filename, $content);
    }
77360
public function createFile(string $fileName): \SplFileInfo
    {
        $fileInfo = new \SplFileInfo($this->getTmpFolder() . '/' . $fileName);
        $pathName = $fileInfo->getPathname();
        if (!file_exists(dirname($pathName))) {
            $this->fileSystem->mkdir(dirname($pathName), self::FILE_MODE);
        }
        $this->fileSystem->touch($pathName);
        $this->fileSystem->chmod($pathName, self::FILE_MODE);
        return $fileInfo;
    }
380595
public function fromFile(string $filename = '', bool $returnArray = false)
    {
        if (empty($filename)) {
            throw new InvalidArgumentException('File name must be specified');
        }

        \set_error_handler(
            function ($error, $message = '') use ($filename) {
                $exMsg = \sprintf('Error reading from "%s": %s', $filename, $message);
                throw new RuntimeException($exMsg, $error);
            },
            E_WARNING
        );

        try {
            $config = $this->transform(\file_get_contents($filename));
            \restore_error_handler();
            return $returnArray ? $config : new Config($config);
        } catch (RuntimeException $e) {
            \restore_error_handler();
            throw $e;
        }
    }
841082
public static File newFile(String fileName) {
		File file = new File(fileName);
		if(file.exists())
			file.delete();
		return file;
	}
1158804
public function loadFile($filename) {
		$this->filename = $filename;


		// If a cache directory was specified,
        // try to load from it
		if ($this->cachePath) {
		    if (! $this->templatesRoot) {
		        $this->templatesRoot = dirname($filename);
            }
		    $cacheFile = $this->makeCacheFilename($this->cachePath, $this->templatesRoot, $this->filename);
            if ( file_exists($cacheFile)
                 && (! file_exists($this->filename) || (filemtime($this->filename) < filemtime($cacheFile)) )
            ) {
                $this->loadFromSerialized(file_get_contents($cacheFile));
                return;
            }
        }

		if(file_exists($filename)) {
			$this->source = file_get_contents($filename);
		} else {
			$message = "File not found: $filename";
			throw new FileNotFoundException($message, $filename);
		}
	}
1227561
public function goReadFile(string $filename)
    {
        $this->__filename  = $filename;
        $this->__type      = self::READ_FILE;

        $this->requestId   = $this->getContext()->getRequestId();
        $requestId         = $this->requestId;

        getInstance()->scheduler->IOCallBack[$this->requestId][] = $this;
        $keys = array_keys(getInstance()->scheduler->IOCallBack[$this->requestId]);
        $this->ioBackKey = array_pop($keys);

        $this->send(function ($filename, $content) use ($requestId) {
            if (empty($this->getContext()) || ($requestId != $this->getContext()->getRequestId())) {
                return;
            }

            if (empty(getInstance()->scheduler->taskMap[$this->requestId])) {
                return;
            }

            $this->result = $content;
            $this->ioBack = true;
            $this->nextRun();
        });

        return $this;
    }
1155621
protected function loadRecipeFile($filename) {
    if (!file_exists($filename)) {
      throw new FileNotFoundException($filename);
    }
    $recipe = Yaml::parse(
      file_get_contents($filename)
    );
    $configs = [$recipe];
    $processor = new Processor();
    $configuration_tree = new ProjectConfiguration();
    $processed_configuration = $processor->processConfiguration(
      $configuration_tree,
      $configs
    );

    return $processed_configuration;
  }
787419
public static function fromFile($filename)
    {
        $records = Collection::fromFile($filename)->toArray();

        if (!count($records)) {
            throw new RecordNotFound();
        }

        return $records[0];
    }
276797
public static function fromFile($filename): self
    {
        if (!is_readable($filename) ||
             false === ($str = file_get_contents($filename))) {
            throw new \RuntimeException("Failed to read $filename.");
        }
        return self::fromString($str);
    }
61603
public function createFile($fileName)
    {
        foreach ($this->languages() as $languageKey) {
            $file = $this->path."/{$languageKey}/{$fileName}.php";
            if (! $this->disk->exists($file)) {
                file_put_contents($file, "<?php \n\n return[];");
            }
        }
    }
1024778
static public function tryCreateFromFile($filename) {
		try {
			$instance = self::createFromFile($filename);
			return $instance;
		} catch (\Exception $exception) {
			return null;
		}
	}
880875
public function downloadFile(string $fileName)
    {
        return $this->file(rawurldecode($fileName), null, ResponseHeaderBag::DISPOSITION_INLINE);
    }
464367
public static function from($filename)
    {
        $extension = strtok(pathinfo($filename, PATHINFO_EXTENSION), '?');

        return self::getMimeTypeFromExtension($extension);
    }
131702
public function theOperationInFile($filename)
    {
        $queryFile = sprintf('%s%s%s', self::$currentFeatureFile->getPath(), DIRECTORY_SEPARATOR, $filename);
        if (file_exists($queryFile)) {
            $file = new File($queryFile);
            $this->client->setGraphQL(file_get_contents($file->getPathname()));
        } else {
            throw new FileNotFoundException(null, 0, null, $queryFile);
        }
    }
1103518
public function msginitFile(string $filename): PoFile
    {
        if (!is_readable($filename)) {
            $source = false;
        } else {
            $source = file_get_contents($filename);
        }
        if (false===$source) {
            throw new FileNotReadableException($filename);
        }
        return $this->msginitString($source, $filename);
    }
301779
public function save($filename)
    {
        $this->setFilename($filename);

        call_user_func_array($this->getFunctionName(), [$this->getImage(), $filename]);

        return $filename;
    }
47317
public static function load($fileName, $separate='/')
    {
        $instance = new static($fileName);
        $instance->setSeparate($separate);

        $filePath = $instance->getFilePath(self::getDir(), $fileName);

        if ($filePath) {
            $instance->setAll($instance->loadFile($filePath));
        } else {
            throw new FileNotExistException('File '. $fileName .' does not exist');
        }

        return $instance;
    }