@param $filename

@throws \Exception
962129
public function deleteFileByName($filename)
    {
        $destinationPath = $this->getDestinationPath();
        $destination = $destinationPath . '/' . $filename;

        if (file_exists($destination)) {
            $files = $this->getFiles();
            foreach ($files as $key => $file) {
                if ($file->file == $filename) {
                    unlink($destination);
                    unset($files[$key]);
                }
            }

            $files = array_values($files);
            $this->repository->files = $files;
            $this->save();
        }
    }
1023904
public static function loadPhpFile($filename)
    {
        $filePath = realpath($filename);

        /**
         * I lifed this from phpunits FileLoader class
         *
         * @see https://github.com/sebastianbergmann/phpunit/pull/2751
         */
        $isReadable = @\fopen($filePath, 'r') !== false;

        if (!$filePath || !$isReadable) {
            throw new \Exception(sprintf("Cannot open file %s \n", $filename));
        }

        include_once $filePath;

        return $filePath;
    }
189806
public function load($filename)
    {
        if ($filename && file_exists($filename)) {
            $this->doc->load($filename, LIBXML_NSCLEAN);
        } else {
            $this->createBasicDocument();
        }
    }
246660
public function open($filename)
    {
        $pathInfo = pathinfo($filename);
        if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) {
            parent::open($filename);
        }
    }
87872
public function deleteFile($fileName, $storageName = '')
    {
        //check whether file is set or not
        if ($fileName == '') {
            AsposeApp::getLogger()->error(Exception::MSG_NO_FILENAME);
            throw new Exception(Exception::MSG_NO_FILENAME);
        }

        //build URI
        $strURI = $this->strURIFile . $fileName;
        if ($storageName != '') {
            $strURI .= '?storage=' . $storageName;
        }
        //sign URI
        $signedURI = Utils::sign($strURI);

        $responseStream = json_decode(Utils::processCommand($signedURI, 'DELETE', '', ''));
        if ($responseStream->Code != 200) {
            return FALSE;
        }
        return TRUE;
    }
1372470
static public function createFromFile($filename) {
		if (!file_exists($filename))
			throw new Exception('Invalid (filename) parameter! File does not exist!');

		$image_info = getimagesize($filename);
		if ($image_info === false)
			throw new Exception('Invalid (filename) parameter! File is corrupted!');

		switch ($image_info[2]) {
			case IMAGETYPE_JPEG:
			case IMAGETYPE_JPEG2000:
				$image = imagecreatefromjpeg($filename);
				break;
			case IMAGETYPE_PNG:
				$image = imagecreatefrompng($filename);
				break;
			case IMAGETYPE_GIF:
				$image = imagecreatefromgif($filename);
				break;
			case IMAGETYPE_WBMP:
				$image = imagecreatefromwbmp($filename);
				break;
			case IMAGETYPE_BMP:
				$image = imagecreatefrombmp($filename);
				break;
			default:
				throw new Exception('Unknown image format!');
				break;
		}

		return new self($image);
	}
842584
public function download($filename) {
    if(!empty($this->pdf->getError())) {
      throw new Exception('Could not create PDF: ' . $this->pdf->getError());
    } else {
      $filename = rtrim(File::create()->setName($filename), '.pdf') . '.pdf';
      $this->pdf->send($filename);
    }
  }
1296090
private function loadConfig($fileName) {
		$config = include($this->path . DIRECTORY_SEPARATOR . $fileName . '.php');
		
		$this->map[$fileName] = $config;
	}
175395
public static function fromFile(string $filename = ''): self
    {
        if (!\file_exists($filename)) {
            throw new \Exception($filename.' does not exist');
        }
        $contents = \file_get_contents($filename);
        if (!\is_string($contents)) {
            throw new \Exception('Could not read file contents');
        }
        return self::fromData($contents);
    }
870214
public function open( $fileName )
	{
		if( !file_exists( $fileName ) )																		// If the tar file doesn't exist...
			throw new Exception( "TGZ file '".$fileName."' is not existing." );
		$this->fileName = $fileName;
		$this->readGzipTar( $fileName );
	}
548117
private static function addConfigFromFile($filename)
    {
        $file_path = self::$default_dir . $filename . ".php";

        if (! file_exists($file_path)) {
            $err_msg = "The file '" . str_replace(['\\','/'], DIRECTORY_SEPARATOR, $file_path) . "' is not found!";
            throw new \Exception($err_msg);
        }

        self::$settings[$filename] = new \Phalcon\Config\Adapter\Php($file_path);
    }
177888
public function handleRename(string $fileName): void
	{
		if ($this->presenter->isAjax() && $this->editable) {
			$this->template->files = [$this->rename($fileName)];
			$this->redrawControl('itemsContainer');
		} else {
			exit;
		}
	}
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);
		}
	}
169298
public function handleDelete(string $fileName): void
	{
		if ($this->presenter->isAjax() && $this->editable) {
			$file = $this->getFileInfo($fileName);
			if ($file->isDir) {
				File::removeDir($this->getFullPath($file->name));
			} else {
				unlink($this->getFullPath($file->name));
			}
			$this->redrawControl('fileManagerContainer');
		} else {
			exit;
		}
	}
626978
public function write($filename)
    {
        if (count($this) == 0) return;
        $file = fopen($filename, 'w');
        fwrite($file, $this->toJson());
        fclose($file);
        unset($file);
    }
132153
public static function autoload($className)
    {
        // validate classname
        if (!preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/m', $className)) {
            throw new Exception("Class name '$className' is invalid");
        }

        $classFile = self::$_baseDir . '/' . str_replace('_', '/', $className) . '.php';

        // check if file exists
        if (!file_exists($classFile)) {
            throw new Exception("File $classFile does not exist!");
        }

        require $classFile;

        if (!class_exists($className) && !interface_exists($className)) {
            throw new Exception("Class $className could not be found!");
        }
    }
471193
public function addFile( $fileName )
	{
		if( !file_exists( $fileName ) )													// Make sure the file we are adding exists!
			throw new Exception( 'File "'.$fileName.'" is not existing' );
		if( $this->containsFile( $fileName ) )											// Make sure there are no other files in the archive that have this same fileName
			throw new Exception( 'File "'.$fileName.'" already existing in TAR' );

		$fileName	= str_replace( "\\", "/", $fileName );
		$fileName	= str_replace( "./", "", $fileName );
		$fileInfo	= stat( $fileName );												// Get file information
		$file		= new File_Reader( $fileName );

		$this->numFiles++;																// Add file to processed data
		$activeFile					= &$this->files[];
		$activeFile['name']			= $fileName;
		$activeFile['mode']			= $fileInfo['mode'];
		$activeFile['user_id']		= $fileInfo['uid'];
		$activeFile['group_id']		= $fileInfo['gid'];
		$activeFile['size']			= $fileInfo['size'];
		$activeFile['time']			= $fileInfo['mtime'];
#		$activeFile['checksum']		= $checksum;
		$activeFile['user_name']	= '';
		$activeFile['group_name']	= '';
		$activeFile['file']			= $file->readString();								// Read in the file's contents
		return TRUE;
	}