Returns relative sub dir of oxconfig 'sDownloadsDir' of
required file from supplied $sFileHash parameter.
Creates dir in case it does not exist.

@param string $sFileHash File hash value

@return string
351169
protected function _getHashedFileDir($sFileHash)
    {
        $sDir = substr($sFileHash, 0, 2);
        $sAbsDir = $this->_getBaseDownloadDirPath() . DIRECTORY_SEPARATOR . $sDir;

        if (!is_dir($sAbsDir)) {
            mkdir($sAbsDir, 0755);
        }

        return $sDir;
    }
89355
public function mkdir($dsthash, $name) {
		if ($this->commandDisabled('mkdir')) {
			return $this->setError(elFinder::ERROR_PERM_DENIED);
		}
		
		if (!$this->nameAccepted($name)) {
			return $this->setError(elFinder::ERROR_INVALID_NAME);
		}
		
		if (($dir = $this->dir($dsthash)) == false) {
			return $this->setError(elFinder::ERROR_TRGDIR_NOT_FOUND, '#'.$dsthash);
		}
		
		$path = $this->decode($dsthash);
		
		if (!$dir['write'] || !$this->allowCreate($path, $name, true)) {
			return $this->setError(elFinder::ERROR_PERM_DENIED);
		}
		
		$dst  = $this->joinPathCE($path, $name);
		$stat = $this->stat($dst); 
		if (!empty($stat)) { 
			return $this->setError(elFinder::ERROR_EXISTS, $name);
		}
		$this->clearcache();
		return ($path = $this->convEncOut($this->_mkdir($this->convEncIn($path), $this->convEncIn($name)))) ? $this->stat($path) : false;
	}
142697
public function getHash()
	{
		if (is_null($this->hash)) {
			if ($this->content != null) {
				$this->hash = sha1($this->content);
			} else {
				$path = ResourceUtil::createTempDir() . DIRECTORY_SEPARATOR . $this->getFilename();
				file_put_contents($path, $this->getStream());
				$this->hash = sha1_file($path);
				unlink($path);
				rmdir(dirname($path));
			}
		}
		return $this->hash;
	}
512212
public function file($hash) {
		$path = $this->decode($hash);
		
		return ($file = $this->stat($path)) ? $file : $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
		
		if (($file = $this->stat($path)) != false) {
			if ($realpath) {
				$file['realpath'] = $path;
			}
			return $file;
		}
		return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
	}
1275874
public function detectFromFile(string $sFile): string
    {
        if (!file_exists($sFile)) {
            return '';
        }

        $rHandle = finfo_open(FILEINFO_MIME_TYPE);
        $sMime   = finfo_file($rHandle, $sFile);

        if ($sMime === 'application/octet-stream' || empty($sMime)) {
            $sMime = $this->oDetector->getType($sFile);
        }

        return $sMime ?? 'application/octet-stream';
    }
1093321
public function getMediaUrl($sFile = '')
    {
        $oConfig = $this->getConfig();

        $sFilePath = $this->getMediaPath($sFile);

        if (!is_readable($sFilePath)) {
            return false;
        }

        if ($oConfig->isSsl()) {
            $sUrl = $oConfig->getSslShopUrl(false);
        } else {
            $sUrl = $oConfig->getShopUrl(false);
        }

        $sUrl = rtrim($sUrl, '/') . $this->_sMediaPath;

        if ($sFile) {
            return $sUrl . $sFile;
        }

        return $sUrl;
    }
388062
public function file(SplFileInfo $file)
	{
		return substr($this->base(hash_file('sha256', $file->getRealPath(), true)), 0, 32);
	}
847595
protected function setHashInEnvironmentFile($hash)
    {
        $envPath = $this->laravel->environmentFilePath();
        $envContent = $this->filesystem->get($envPath);

        $regex = '/UNDER_CONSTRUCTION_HASH=\S+/';

        if (preg_match($regex, $envContent)) {
            $hash = str_replace(['\\', '$'], ['', '\$'], $hash);
            $envContent = preg_replace($regex, $this->newLine($hash), $envContent);
        } else {
            $envContent .= "\n".$this->newLine($hash)."\n";
        }

        $this->filesystem->put($envPath, $envContent);
    }
604446
public function get_file_by_hash($pathnamehash) {
        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.pathnamehash = ?";
        if ($filerecord = $DB->get_record_sql($sql, array($pathnamehash))) {
            return $this->get_file_instance($filerecord);
        } else {
            return false;
        }
    }
25173
public function getResourceUrl($sFile = null)
    {
        if ($sFile) {
            $sValue = $this->getConfig()->getResourceUrl($sFile, $this->isAdmin());
        } elseif (($sValue = $this->getViewConfigParam('basetpldir')) === null) {
            $sValue = $this->getConfig()->getResourceUrl('', $this->isAdmin());
            $this->setViewConfigParam('basetpldir', $sValue);
        }

        return $sValue;
    }
773581
private function getDirectoryHash($key)
    {
        $key = \md5($key);

        $level1 = \substr($key, 0, 1);
        $level2 = \substr($key, 1, 1);
        $level3 = \substr($key, 2, 1);

        $directoryHash = $level1 . DIRECTORY_SEPARATOR . $level2 . DIRECTORY_SEPARATOR . $level3;
        $this->createCacheHashDirectory($directoryHash);

        return $directoryHash;
    }
262860
protected function findViewFromHash($hash)
    {
        $finder = app('view')->getFinder();

        if (isset($this->reflection['viewfinderViews'])) {
            $property = $this->reflection['viewfinderViews'];
        } else {
            $reflection = new \ReflectionClass($finder);
            $property = $reflection->getProperty('views');
            $property->setAccessible(true);
            $this->reflection['viewfinderViews'] = $property;
        }

        foreach ($property->getValue($finder) as $name => $path){
            if (sha1($path) == $hash || md5($path) == $hash) {
                return $name;
            }
        }
    }
720023
public function getAltImageUrl($sFilePath, $sFile, $blSSL = null)
    {
        $oConfig = \OxidEsales\Eshop\Core\Registry::getConfig();

        $sAltUrl = $oConfig->getConfigParam('sAltImageUrl');
        if (!$sAltUrl) {
            $sAltUrl = $oConfig->getConfigParam('sAltImageDir');
        }

        if ($sAltUrl) {
            if ((is_null($blSSL) && $oConfig->isSsl()) || $blSSL) {
                $sSslAltUrl = $oConfig->getConfigParam('sSSLAltImageUrl');
                if (!$sSslAltUrl) {
                    $sSslAltUrl = $oConfig->getConfigParam('sSSLAltImageDir');
                }

                if ($sSslAltUrl) {
                    $sAltUrl = $sSslAltUrl;
                }
            }

            if (!is_null($sFile)) {
                $sAltUrl = Registry::getUtils()->checkUrlEndingSlash($sAltUrl) . $sFilePath . $sFile;
            }
        }

        return $sAltUrl;
    }
1371750
public File getFile(String hash)
   {
      // work with digest
      return new File(channel.rootDir, channel.makeFilePath(hash, 0));
   }
180324
def file_hash(load, fnd):
    '''
    
    '''
    path = fnd['path']
    ret = {}

    if 'env' in load:
        # "env" is not supported; Use "saltenv".
        load.pop('env')

    if load['saltenv'] not in envs():
        return {}

    # if the file doesn't exist, we can't get a hash
    if not path or not os.path.isfile(path):
        return ret

    # set the hash_type as it is determined by config-- so mechanism won't change that
    ret['hash_type'] = __opts__['hash_type']

    # check if the hash is cached
    # cache file's contents should be "hash:mtime"
    cache_path = os.path.join(
        __opts__['cachedir'],
        'minionfs',
        'hash',
        load['saltenv'],
        '{0}.hash.{1}'.format(fnd['rel'], __opts__['hash_type'])
    )
    # if we have a cache, serve that if the mtime hasn't changed
    if os.path.exists(cache_path):
        try:
            with salt.utils.files.fopen(cache_path, 'rb') as fp_:
                try:
                    hsum, mtime = salt.utils.stringutils.to_unicode(fp_.read()).split(':')
                except ValueError:
                    log.debug(
                        'Fileserver attempted to read incomplete cache file. '
                        'Retrying.'
                    )
                    file_hash(load, fnd)
                    return ret
                if os.path.getmtime(path) == mtime:
                    # check if mtime changed
                    ret['hsum'] = hsum
                    return ret
        # Can't use Python select() because we need Windows support
        except os.error:
            log.debug(
                'Fileserver encountered lock when reading cache file. '
                'Retrying.'
            )
            file_hash(load, fnd)
            return ret

    # if we don't have a cache entry-- lets make one
    ret['hsum'] = salt.utils.hashutils.get_hash(path, __opts__['hash_type'])
    cache_dir = os.path.dirname(cache_path)
    # make cache directory if it doesn't exist
    if not os.path.exists(cache_dir):
        os.makedirs(cache_dir)
    # save the cache object "hash:mtime"
    cache_object = '{0}:{1}'.format(ret['hsum'], os.path.getmtime(path))
    with salt.utils.files.flopen(cache_path, 'w') as fp_:
        fp_.write(cache_object)
    return ret
1265069
public function ls($hash) {
		if (($dir = $this->dir($hash)) == false || !$dir['read']) {
			return false;
		}
		
		$list = array();
		$path = $this->decode($hash);
		
		foreach ($this->getScandir($path) as $stat) {
			if (empty($stat['hidden']) && $this->mimeAccepted($stat['mime'])) {
				$list[] = $stat['name'];
			}
		}

		return $list;
	}
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;
    }