Generate File Name Hash based on filename, request params and request options

@param string $file

@return string
502924
protected function generateCacheFile($file)
    {
        $cacheSalt = serialize(array(
            $this->request->options,
            MUNEE_USING_URL_REWRITE,
            MUNEE_DISPATCHER_FILE
        ));
        $params = serialize($this->request->params);
        $ext = pathinfo($file, PATHINFO_EXTENSION);

        $fileHash = md5($file);
        $optionsHash = md5($params . $cacheSalt);

        $cacheDir = $this->cacheDir . DS . substr($fileHash, 0, 2);

        Utils::createDir($cacheDir);

        return $cacheDir . DS . substr($fileHash, 2) . '-' . $optionsHash . '.' . $ext;
    }
730258
public function proposeFilename(File $file, $suffix)
    {
        if ($file instanceof UploadedFile) {
            $fileName = $file->getClientOriginalName();
        } else {
            $fileName = $file->getBasename();
        }
        $ret = preg_replace('/[^\w.]+/', '-', strtolower($fileName));
        $ret = preg_replace('/-+/', '-', $ret);
        if ($suffix) {
            $ext = (string)pathinfo($ret, PATHINFO_EXTENSION);
            $fn = (string)pathinfo($ret, PATHINFO_FILENAME);
            $ret = sprintf('%s-%d.%s', trim($fn, '.'), $suffix, $ext);
        }
        return $ret;
    }
547642
protected function prepareSeedClass($file)
    {
        $extension = $file->getExtension();
        if ($extension !== 'php') {
            return null;
        }
        return '\\' . str_replace('.' . $extension, '', $file->getFilename());
    }
898978
public function getFilename($file)
    {
        // 获取文件的后缀名，因图片从剪贴板里黏贴时后缀名为空，所以此处确保后缀一直存在
        $this->extension = strtolower($file->getClientOriginalExtension()) ?: 'png';

        $randomName = str_random($this->randomLength);

        if ($this->filename) {
            return $this->filename . $this->extension;
        }

        if ($this->filePrefix) {
            return $this->filePrefix . '_' . $randomName . '.' . $this->extension;
        }

        return $randomName . '.' . $this->extension;
    }
785102
public function createFileName($file)
    {
        if ( ! is_null($this->elfinderFilePath) ) {
            return $this->getFileName();
        }
        if ( is_string($file) ) {
            return substr( strrchr( $file, '/' ), 1 );
        }

        $filename = $file->getClientOriginalName();
        $mime = $file->getClientOriginalExtension();
        $parts = explode('.',$filename);
        array_pop($parts);
        return str_slug( implode(' ', $parts), '-' ) . '_' . time() .  '.' . $mime;
    }
510485
public function hashName($path = null)
    {
        if (! is_null($path)) {
            $path = rtrim($path, '/\\') .DS;
        }

        return $path .md5_file($this->path()) .'.' .$this->extension();
    }
701678
public function getBindingForFile( $file ) {
		$engine_key = $this->default;

		foreach ( $this->bindings as $suffix => $engine ) {
			if ( substr( $file, -strlen( $suffix ) ) === $suffix ) {
				$engine_key = $engine;
				break;
			}
		}

		return $engine_key;
	}
929720
public function hashName( $path = null )
	{
		if ( $path )
		{
			$path = rtrim( $path, '/' ) . '/';
		}

		return $path . md5_file( $this->path() ) . '.' . $this->extension();
	}
382449
private String getFilename(String filename, File file) {
        if (!file.exists()) {
            file.mkdirs();
        }
        String ext = ".jpg";
        //get extension
        /*if (Pattern.matches("^[.][p][n][g]", filename)){
            ext = ".png";
        }*/

        return (file.getAbsolutePath() + "/IMG_" + new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()) + ext);

    }
928144
public static function file_output($file, $options=null) {
        $id = '';
        if (!is_array($options)) {
            $options = array();
        }
        if (!array_key_exists('entry', $options)) {
            $options['entry'] = true;
        }
        if (!empty($options['entry'])) {
            $path = 'portfolio:' . self::file_id_prefix() . $file->get_id();
        } else {
            $path = self::get_file_directory() . $file->get_filename();
        }
        $attributes = array();
        if (!empty($options['attributes']) && is_array($options['attributes'])) {
            $attributes = $options['attributes'];
        }
        $attributes['rel']    = 'enclosure';
        return self::make_tag($file, $path, $attributes);
    }
91592
public function getName($file = "", $default = null)
    {

        $file = (empty($file) && isset($this->file)) ? $this->file : $file;

        if (empty($file)) {
            return $default;
        }

        //Determine the filename
        return pathinfo($file, PATHINFO_FILENAME);
    }
1341065
private function findAvailableName($file)
    {
        $name = basename($file);

        if (!file_exists($this->directory.'/'.$name)) {
            return $name;
        }

        $dotPos = strrpos($name, '.');
        $prefix = substr($name, 0, $dotPos);
        $suffix = substr($name, $dotPos);

        $count = 1;
        do {
            $name = $prefix.'_'.$count.$suffix;
            $count++;
        } while (file_exists($this->directory.'/'.$name));

        return $name;
    }
792079
protected function getStoreName(UploadedFile $file)
    {
        if ($this->useUniqueName) {
            return $this->generateUniqueName($file);
        }

        if ($this->useSequenceName) {
            return $this->generateSequenceName($file);
        }

        if ($this->name instanceof \Closure) {
            return $this->name->call($this, $file);
        }

        if (is_string($this->name)) {
            return $this->name;
        }

        return $file->getClientOriginalName();
    }
320511
public function sanitize($file)
    {
        // Let's build an ASCII-only version of name, to avoid filesystem-specific encoding issues.
        $asciiName = Core::make('helper/text')->asciify($file);
        // Let's keep only letters, numbers, underscore and dots.
        $asciiName = trim(preg_replace(["/[\\s]/", "/[^0-9A-Z_a-z-.]/"], ["_", ""], $asciiName));
        // Trim underscores at start and end
        $asciiName = trim($asciiName, '_');
        if (!strlen(str_replace('.', '', $asciiName))) {
            // If the resulting name is empty (or we have only dots in it)
            $asciiName = md5($file);
        } elseif (preg_match('/^\.\w+$/', $asciiName)) {
            // If the resulting name is only composed by the file extension
            $asciiName = md5($file) . $asciiName;
        }

        return $asciiName;
    }
63361
private function generateFilename()
    {
        if ($this->filename) {
            return $this->filename;
        }

        if ($this->hash_filename) {
            return $this->generateHash();
        }

        return $this->sanitizeFileName($this->source->filename());
    }
510628
public function checkFilename($file)
    {
        $newFilename  = $file;
        $parts        = pathinfo($file);
        $origFilename = $parts['filename'];
        $ext          = (isset($parts['extension']) && ($parts['extension'] != '')) ? '.' . $parts['extension'] : null;

        $i = 1;

        while (file_exists($this->uploadDir . DIRECTORY_SEPARATOR . $newFilename)) {
            $newFilename = $origFilename . '_' . $i . $ext;
            $i++;
        }

        return $newFilename;
    }
1363313
private function resolveFilename($file)
    {
        if (empty($file)) {
            return null;
        }

        if (
            ($file instanceof UploadedFileInterface && $file->getError() === 0)
            || $file instanceof StreamableInterface
        ) {
            return StreamWrapper::getFilename($file->getStream());
        }

        if (is_array($file)) {
            if (!isset($file['tmp_name'])) {
                return null;
            }

            $file = $file['tmp_name'];
        }

        if (!is_string($file) || !$this->files->exists($file)) {
            return null;
        }

        return $file;
    }