This returns the hash for a file.

@param string $fileName This can be either the absolute file name or the
file name without the path prefix.

@return string The file's hash.
326582
public function getHash($fileName)
    {
        if (array_key_exists($fileName, $this->data)) {
            return $this->data[$fileName];
        } else if (array_key_exists($this->_makeRelative($fileName), $this->data)) {
            return $this->data[$this->_makeRelative($fileName)];
        } else {
            return null;
        }
    }
517859
private function getCacheFileName($name)
    {
        $name = hash($this->options['hash_type'], $name);

        if ($this->options['cache_subdir']) {
            $name = substr($name, 0, 2).DIRECTORY_SEPARATOR.substr($name, 2);
        }

        if ($this->options['prefix']) {
            $name = $this->options['prefix'].DIRECTORY_SEPARATOR.$name;
        }

        $filename = $this->options['path'].$name.'.php';
        $dir      = dirname($filename);
        if (!is_dir($dir)) {
            mkdir($dir, 0755, true);
        }

        return $filename;
    }
760939
protected function getFilename($key)
    {
        $sha1 = sha1($key);
        $result = $this->path . '/' . substr($sha1, 0, 2) . '/' . substr($sha1, 2) . '.php';

        return $result;
    }
233384
def get_hash_for_filename(filename, hashfile_path):
    """"""
    filehash = ''
    with open(hashfile_path, 'r') as stream:
        for _cnt, line in enumerate(stream):
            if line.rstrip().endswith(filename):
                filehash = re.match(r'^[A-Za-z0-9]*', line).group(0)
                break
    if filehash:
        return filehash
    raise AttributeError("Filename %s not found in hash file" % filename)
839258
public function getOriginal($filename)
    {
        $path = $this->getImagePath($filename);

        return $this->buildResponse(file_get_contents($path));
    }
519875
public static function path($filename)
    {
        if ($filename[0] != "/") {
            $filename = static::$path . "/" . $filename;
        }

        if (substr($filename, -5) != ".json") {
            $filename .= ".json";
        }

        $path = pathinfo($filename, PATHINFO_DIRNAME);

        # Ensure the cache directory exists
        if (!is_dir($path)) {
            if (!mkdir($path, 0777, true)) {
                throw new \Exception("Unable to create cache directory (" . $path . ")");
            }
        }

        # Ensure directory is writable
        if (!is_writable($path)) {
            if (!chmod($path, 0777)) {
                throw new \Exception("Cache directory (" . $path . ") is not writable");
            }
        }

        return $filename;
    }
1213948
def get_hashed_filename(name, file, suffix=None):
    
    basename, hash, ext = split_filename(name)
    file.seek(0)
    new_hash = '.%s' % md5(file.read()).hexdigest()[:12]
    if suffix is not None:
        basename = '%s_%s' % (basename, suffix)
    return '%s%s%s' % (basename, new_hash, ext)
206753
def get_hash(fName, readSize, dire=pDir()):
    
    if not fileExists(fName, dire):
        return -1
    readSize = readSize * 1024 # bytes to be read
    fName = os.path.join(dire, fName) # name coupled with path
    with open(fName, 'rb') as f:
        size = os.path.getsize(fName)
        if size < readSize * 2:
            return -1
        data = f.read(readSize)
        f.seek(-readSize, os.SEEK_END)
        data += f.read(readSize)
    return md5(data).hexdigest()
1193548
public function getFileName($fileName, $ext='')
    {
        if (empty($ext)) {
            $fileName= substr($fileName, 0, strrpos($fileName, '.', -1));
        }
        else {
            if (substr($ext, 0, 1)!='.') {
                $ext= '.'.$ext;
            }

            if (substr($fileName, -(strlen($ext)))==$ext) {
                $fileName= substr($fileName, 0, -(strlen($ext)));
            }
        }

        $exFileName = explode('/', Utils\Util::toFormat($fileName, '/'));

        return end($exFileName);
    }
595501
public function findTemplateFile($filename)
    {
        foreach ($this->dir as $index => $dirname)
        {
            if (is_dir($dirname) && file_exists($dirname . '/' . $filename)) {
                return $dirname . '/' . $filename;
            }
        }

        return null;
    }
1161875
public static function getClassFromFileName($filename)
    {
        $filename = basename($filename);

        $rpos = strrpos($filename, '.');

        if ($rpos != -1) {
            $filename = substr($filename, 0, $rpos);
        }

        return $filename;
    }
45652
public static function getFileNameWithoutExtension($fileName)
    {
        $matches = [];

        if (is_string($fileName) && (bool)preg_match('|(.+)\.(.+)|', $fileName, $matches)) {
            return $matches[1];
        }

        return '';
    }
341031
public function cssVersion($fileName)
    {
        $filePath = sprintf("%s/../web%s", $this->kernelRootDir, $fileName);

        if (true === file_exists($filePath)) {
            return sprintf("%s?v=%s", $fileName, substr(md5_file($filePath), 0, 5));
        }

        return sprintf("%s?v=%s", $fileName, substr(sha1(microtime()), 0, 6));
    }
887205
public function read($fileName=null)
    {
        $this->_resetFileName($fileName);

        $manifest = array();
        $hashLen = ($this->hashEncoding == 'sha1') ? 40 : 32;
        $lines = readLines($this->fileName, $this->fileEncoding);

        foreach ($lines as $line) {
            $hash = trim(substr($line, 0, $hashLen));
            $payload = trim(substr($line, $hashLen));

            if (strlen($payload) > 0) {
                $manifest[$payload] = $hash;
            }
        }

        $this->data = $manifest;
        return $manifest;
    }
403575
public function fetch($filename): string {
        $data = file_get_contents($this->_getFilePath($filename));
        if ($this->_gzip) {
            $probablyGzipped = bin2hex(substr($data, 0, 2)) == '1f8b';
            $data = $probablyGzipped ? gzdecode($data) : $data;
        }
        return $data;
    }
797168
private function getFileContentSafety($filename) {
        $file = fopen($filename, 'r');
        flock($file, LOCK_SH);
        $content = file_get_contents($filename);
        flock($file, LOCK_UN);
        fclose($file);

        return $content;
    }
342433
protected function getFileName (string $fileName)
    {
        if (!$fileName && filter_var ($fileName, FILTER_VALIDATE_URL) === false) {
            return null;
        }

        $explodeFileURL = explode ('/', $fileName);
        $fileName       = end ($explodeFileURL);

        return sanitizeString (pathinfo ($fileName, PATHINFO_FILENAME)) . '.' . pathinfo ($fileName, PATHINFO_EXTENSION);
    }