Try to find a DB reference for this parsed file ID that doesn't have an hash. Return a file tuple if a
equivalent file is found.
@param ParsedFileID $parsedFileID
@return array|null
558554
private function resolveHashless(ParsedFileID $parsedFileID)
    {
        $filename = $parsedFileID->getFilename();
        $variant = $parsedFileID->getVariant();

        // Let's try to match the plain file name
        /** @var File $file */
        $file = Versioned::withVersionedMode(function () use ($filename) {
            Versioned::set_stage($this->getVersionedStage());
            return File::get()->filter(['FileFilename' => $filename])->first();
        });

        if ($file) {
            return [
                'Filename' => $filename,
                'Hash' => $file->getHash(),
                'Variant' => $variant
            ];
        }

        return null;
    }
356754
private static function findFile($file = null) {
    if (null !== $file) {
      // Get actual file path
      $rfile = realpath($file);

      // If the file cannot be found, except away
      if (false === $rfile) {
        throw new \Exception(__CLASS__ . ": Database file '{$file}' does not seem to exist.", self::EXCEPTION_DBFILE_NOT_FOUND);
      }

      return $rfile;
    } else {
      // Try to get current path
      $current = realpath(dirname(__FILE__));

	  if (false === $current) {
        throw new \Exception(__CLASS__ . ": Cannot determine current path.", self::EXCEPTION_NO_PATH);
      }
      // Try each database in turn
      foreach (self::$databases as $database) {
        $rfile = realpath("{$current}/{$database}.BIN");
        if (false !== $rfile) {
          return $rfile;
        }
      }
      // No candidates found
      throw new \Exception(__CLASS__ . ": No candidate database files found.", self::EXCEPTION_NO_CANDIDATES);
    }
  }
583116
protected function getSerializeFilename($parsedFiles) {
    if (!$this->cachePath) {
      return null;
    }
    $path = $this->fileUtil->realpath($this->cachePath).'/';
    $filename = $path.'wcmf_config_'.md5($this->fileUtil->realpath($this->configPath).'/'.join('_', $parsedFiles));
    return $filename;
  }
147651
public function getCacheData($pCoord)
    {
        if ($pCoord === $this->currentObjectID) {
            return $this->currentObject;
        }
        $this->storeData();

        //    Check if the entry that has been requested actually exists
        if (!isset($this->cellCache[$pCoord])) {
            //    Return null if requested entry doesn't exist in cache
            return null;
        }

        //    Set current entry to the requested entry
        $this->currentObjectID = $pCoord;
        fseek($this->fileHandle, $this->cellCache[$pCoord]['ptr']);
        $this->currentObject = unserialize(fread($this->fileHandle, $this->cellCache[$pCoord]['sz']));
        //    Re-attach this as the cell's parent
        $this->currentObject->attach($this);

        //    Return requested entry
        return $this->currentObject;
    }
1189723
private function includeFileForId($id)
	{
		$fileName = $this->getFilename($id);

		if (\file_exists($fileName)) {
			return include $fileName;
		}

		return null;
	}
494708
public function guessFileType(FileId $fileId)
    {
        $extension = strtolower(\pathinfo($fileId->id(), PATHINFO_EXTENSION));

        foreach($this->fileTypeExtensions as $fileType => $extensions) {
            if(in_array($extension, $extensions)) {
                return $fileType;
            }
        }

        return 'file';
    }
143052
protected function getOriginalFilename($fileID)
    {
        $parsedFiledID = $this->getPublicResolutionStrategy()->parseFileID($fileID);
        return $parsedFiledID ? $parsedFiledID->getFilename() : null;
    }
1217253
public function getPreviousImage($guid) {
		$imageList = $this->getImageList();
		$key = array_search($guid, $imageList);
		if ($key === false) {
			return null;
		}
		$key--;
		if ($key < 0) {
			return get_entity(end($imageList));
		}
		return get_entity($imageList[$key]);
	}
918668
protected function get_file() {
        if (!$this->file) {
            return null;
        }
        // The get_file_by_id call can return false, so normalise to null.
        $file = get_file_storage()->get_file_by_id($this->file);
        return ($file) ? $file : null;
    }
1061320
protected function getFilesystem($ident)
    {
        if (isset($this->filesystems[$ident])) {
            return $this->filesystems[$ident];
        }

        return null;
    }
595
public function getId()
    {
        if ($output = $this->execute('fsutil file queryfileid', $this->path)) {
                if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) {
                return $matches[0];
            }
        }
    }
1200712
public function get_file_info($fileid) {
        $this->reset_state();
        $result = $this->request($this->make_url("/files/$fileid"));
        return json_decode($result);
    }
104155
public function get_file_by_id($fileid) {
        global $DB;

        $sql = "SELECT ".self::instance_sql_fields('f', 'r')."
                  FROM {files} f
             LEFT JOIN {files_reference} r
                       ON f.referencefileid = r.id
                 WHERE f.id = ?";
        if ($filerecord = $DB->get_record_sql($sql, array($fileid))) {
            return $this->get_file_instance($filerecord);
        } else {
            return false;
        }
    }
290580
public function getFileId(): \Psr\Http\Message\UriInterface
    {
        if (!$this->fileId) {
            return new Uri();
        }

        return $this->fileId;
    }
1240747
public function fileLookup($fileId) {
		$member = $this->securityContext->getMember();
		if (!$member) {
			return;
		}
		
		$file = File::get()->filter(array('ID' => $fileId, 'OwnerID' => $member->ID))->first();
		if ($file && $file->ID) {
			return array(
				'Title'		=> $file->Title,
				'Link'		=> $file->getAbsoluteURL(),
				'IsImage'	=> $file instanceof Image,
				'ID'		=> $file->ID,
			);
		}
	}
102646
protected function parseFileID($fileID)
    {
        /** @var ParsedFileID $parsedFileID */
        $parsedFileID = $this->getProtectedResolutionStrategy()->parseFileID($fileID);
        return $parsedFileID ? $parsedFileID->getTuple() : null;
    }
1072144
public function get($uid) {
  $query = new \Peyote\Select('media');
  $query->columns('media.uid',
                  'media.file',
                  'media.format',
                  'media.hash',
                  'media.width',
                  'media.height',
                  'media.size',
                  'media.type',
                  'storage.type AS storage_type',
                  'storage.id AS storage_id',
                  'storage.path',
                  'storage.endpoint',
                  'storage.bucket')
        ->join('storage', 'inner')
        ->on('storage.id', '=', 'media.storage')
        ->where('media.uid', '=', $uid);
  $results = $this->db->fetch($query);
  $formatter = new \Rych\ByteSize\Formatter\Binary;
  $bytesize = new \Rych\ByteSize\ByteSize($formatter);
  foreach ($results as $m) {
   $result[$m['type']] = $m;
   $siteURL = $this->siteURL();
   switch ($m['storage_type']) {
    case 'local':
     $result[$m['type']]['url'] = $siteURL['scheme'] .'://' . $m['path'] . $result[$m['type']]['file'];
     break;
    case 's3':
     $result[$m['type']]['url'] = $siteURL['scheme'] .'://' . $m['bucket'] . '.' . $m['endpoint'] . '/' . $result[$m['type']]['file'];
     break;
   }
   $result[$m['type']]['readable_size'] = $bytesize->format($result[$m['type']]['size']);
  }
  return $result;
 }