First check this file on FS
If it doesn't exist - try to download it from DB

@param string $filename
@return bool
357237
public function fileExists($filename)
    {
        if ($this->mediaDirectory->isFile($filename)) {
            return true;
        } else {
            return $this->coreFileStorageDatabase->saveFileToFilesystem(
                $this->mediaDirectory->getAbsolutePath($filename)
            );
        }
    }
1024778
static public function tryCreateFromFile($filename) {
		try {
			$instance = self::createFromFile($filename);
			return $instance;
		} catch (\Exception $exception) {
			return null;
		}
	}
961320
public function open($filename)
    {
        if (!$this->exists($filename) || false === $content = file_get_contents($filename)) {
            throw new FileNotFoundException($filename);
        }

        return $this->makeFile($filename, $content);
    }
439244
public function load($filename)
    {
        if (!file_exists($filename)) {
            throw new \Exception('Ini file "' . $filename . '" doesn\'t exist.');
            return false;
        }
        $this->filename = $filename;
        return $this;
    }
1285684
protected function _backup($filename)
	{
		if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
		{
			$res = ibase_backup($service, $this->db->database, $filename.'.fbk');

			// Close the service connection
			ibase_service_detach($service);
			return $res;
		}

		return FALSE;
	}
224439
public function loadFromFile($FileName)
    {
        if (! empty($FileName)) {
            $this->FileName = $FileName;
            $result = $this->_openSHPFile();
        } else {
            /* We operate on buffer emulated by readSHP / eofSHP */
            $result = true;
        }

        if ($result && ($this->_openDBFFile())) {
            if (! $this->_loadHeaders()) {
                $this->_closeSHPFile();
                $this->_closeDBFFile();

                return false;
            }
            if (! $this->_loadRecords()) {
                $this->_closeSHPFile();
                $this->_closeDBFFile();

                return false;
            }
            $this->_closeSHPFile();
            $this->_closeDBFFile();

            return true;
        }

        return false;
    }
10262
public function isFile($filename)
    {
        $absolutePath = $this->parser->absoluteFilePath($filename);

        return file_exists($absolutePath) && is_file($absolutePath) ? $absolutePath : null;
    }
707865
protected function getFile($filename)
    {
        try {
            $api = $this->client->api('repositories');
            /* @var Repositories $api */
            $file = $api->getFile($this->raw['path_with_namespace'], $filename, 'master');
            if ('base64' === $file['encoding']) {
                return base64_decode($file['content'], true);
            }
        } catch (\Exception $e) {
            //file not found
        }
    }
520570
protected function isCached($filename)
    {
        if (! empty($this->cacheDir)) {
            return false;
        }

        $cacheFile = $this->cacheDir . DIRECTORY_SEPARATOR . $filename . ".cache";

        if (file_exists($cacheFile)
            && is_array($this->cacheContent = include($cacheFile))
            && $this->cacheContent["_chk"] == filemtime($cacheFile)
        ) {
            return true;
        }

        return false;
    }
705793
public static function loadFile($fileName)
  {
    if (!preg_match('/\.ini$/i', $fileName)) {
      $fileName .= '.ini';
    }
    if (!static::isFileLoaded($fileName)) {
      self::$files[] = $fileName;
      return static::loadFileInMemory($fileName);
    }
    return false;
  }
786142
public function download($filename = 'backup.zip')
	{
		if ( ! preg_match('|.+?\.zip$|', $filename))
		{
			$filename .= '.zip';
		}

		$this->factory->helpers->load('download');
		$get_zip = $this->get_zip();
		$zip_content =& $get_zip;

		force_download($filename, $zip_content);
	}
46651
protected function getFile($filename)
    {
        try {
            $file = $this->client->repos()->contents()->show($this->raw['owner']['login'], $this->raw['name'], $filename);
            if ('base64' === $file['encoding']) {
                return base64_decode($file['content'], true);
            }
        } catch (\Exception $e) {
            //file not found
        }
    }
1224941
public function fileExists($filename)
    {
        return isset($this->_fileHandlers[$filename]) ||
               file_exists($this->_dirPath . '/' . $filename);
    }
869157
public function containsFile( $fileName )
	{
		if( !$this->numFiles )
			return FALSE;
		foreach( $this->files as $key => $information )
			if( $information['name'] == $fileName )
				return TRUE;
	}
937484
public function open($filename)
    {

        if (!is_file($filename)) return false;

        $this->file       = @(string)$filename;
        $this->group      = @(int)filegroup($filename);
        $this->owner      = @(int)fileowner($filename);
        $this->size       = @(int)filesize($filename);
        $this->type       = @(string)filetype($filename);
        $this->accessed   = @(int)fileatime($filename);
        $this->changed    = @(int)filectime($filename);
        $this->modified   = @(int)filemtime($filename);
        $this->permission = @(int)fileperms($filename);
        $this->f_inode    = @ fileinode($filename);
        $this->writeable  = @(bool)is_writable($filename);
        $this->readable   = @(bool)is_readable($filename);
        $this->mime_type  = @(string)mime_content_type($filename);
        $this->_get_path();
        $this->_extract_filename();
        $this->_extract_file_extension();

        return true;
    }
161342
private function updateFile($filename)
        {
                // fetch remote file:
                $file_contents = $this->fetchUrl(self::DOWNLOAD_BASE_URL.$filename);

        if ($file_contents === false) return false;

        if (sha1($file_contents) != $this->getCurrentFileHash($filename)) {
            try {
                throw new Exception("PHPIDS-Update: SHA1-hash of the downloaded file ($filename) is incorrect! (Download failed or Man-in-the-Middle). SHA1 of the file in the trunk: ".sha1($file_contents).", SHA1, provided by phpids.org: ".$this->getCurrentFileHash($filename));
            } catch (Exception $e) {
                return false;
            }
                }

                if (strlen($file_contents) <= 100) {
                        return false;
                }

                // overwrite file contents
                if (!file_put_contents($this->phpids_base.$filename, $file_contents)) {
                        return false;
                }

                return true;
        }
1219046
public function open($filename)
    {
        if (true === $this->openned) {
            $this->close();
        }
        if (!file_exists(self::TMP_DIR)) {
            mkdir(self::TMP_DIR);
        }
        $this->filename = $filename;
        $this->pclzip = new \PclZip($this->filename);
        $this->openned = true;
        return true;
    }