Returns a filename with the next follow-up-number.
F.i.: cookie.jpg -> cookie-2.jpg, cookie-15.jpg -> cookie-16.jpg

@param string $filename
@return string
349336
public static function getCumulativeFilename($filename) {
        $filename = self::formatFilename($filename);

        $filenameParts = explode('.', $filename);
        $ext = array_pop($filenameParts);
        $base = implode('.', $filenameParts);
        $base = preg_match('/' . self::SEPERATOR . '\d+$/', $base) ?
            preg_replace_callback(
                '/' . self::SEPERATOR . '(\d+)$/',
                function ($matches) {
                    return Garp_File::SEPERATOR . ++$matches[1];
                },
                $base
            ) :
            $base . self::SEPERATOR . '2'
        ;

        return $base . '.' . $ext;
    }
869460
public function getCookie($filename){
		$data = S($filename);
		if($data){
			$login=json_decode($data,true);
			$send_snoopy = new Snoopy;
			$send_snoopy->rawheaders['Cookie']= $login['cookie'];
			$send_snoopy->maxredirs = 0;
			$url = "https://mp.weixin.qq.com/cgi-bin/home?t=home/index&lang=zh_CN&token=".$login['token'];
			$send_snoopy->fetch($url);
			$header = $send_snoopy->headers;
			$this->log('header:'.print_r($send_snoopy->headers,true));
			if( strstr($header[3], 'EXPIRED')){
				return $this->login();
			}else{
				$this->_token =$login['token'];
				return $login['cookie'];
			}
		}else{
			return $this->login();
		}
	}
114745
public function locateName($fileName)
    {
        $list = $this->zip->listContent();
        $listCount = count($list);
        $list_index = -1;
        for ($i = 0; $i < $listCount; ++$i) {
            if (strtolower($list[$i]["filename"]) == strtolower($fileName) ||
                strtolower($list[$i]["stored_filename"]) == strtolower($fileName)) {
                $list_index = $i;
                break;
            }
        }
        return ($list_index > -1);
    }
9337
public function getFileByName($filename)
    {
        $files = $this->getFiles();
        foreach ($files as $file) {
            if ($filename == $file->file) {
                return $file;
            }
        }

        return null;
    }
610293
public static function cleanFilename($filename,$replacement='-'){
		$filename = str_replace("\0",'',$filename);
		$filename = preg_replace('#[^a-zA-Z0-9._-]+#',$replacement,$filename);
		if(strlen($filename)>255){
			$ext = substr($filename,strrpos($filename,'.'));
			$name = substr($filename,0,255-strlen($ext));
			$filename = $name.$ext;
		}
		return $filename;
	}
1068530
protected function generateFileName($fileName = null)
    {
        $sha1Hash = $fileName === null ? sha1($this->fileContents) : $fileName;

        $resultFilePath = $sha1Hash;
        if ($fileType = $this->guessFileType()) {
            $resultFilePath .= '.'.$fileType;
        }

        return trim($resultFilePath, '/');
    }
888266
public static function safeFilename($filename)
    {
        Deprecated::method(3.0);

        $filename = rawurlencode($filename); // Use 'rawurlencode', because we prefer '%20' over '+' for spaces.
        $filename = str_replace('%2F', '/', $filename);

        if (substr($filename, 0, 1) == '/') {
            $filename = substr($filename, 1);
        }

        return $filename;
    }
1300212
protected function getUniqueFilename($fileName)
    {
        $value = uniqid(md5($fileName));
        $ext = pathinfo($fileName, PATHINFO_EXTENSION);
        if (!empty($ext)){
            $value .= '.' . $ext;
        }
        return static::FILE_DIR . '/' . $value;
    }
1199836
function getFilename(){
		if($content_disposition = $this->getHeaderValue("Content-Disposition")){
			if(preg_match('/filename="(.*?)"/',$content_disposition,$matches)){
				return $matches[1];
			}
		}
		if(preg_match("/([^\\/?]+)(\\?.*|)$/",$this->_Uri,$matches)){
			return $matches[1];
		}
	}
1209700
protected function getFileName()
    {
        $fileName = parent::getFileName();

        if ($this->maxCount !== false) {
            $fileName = strtr($fileName, [$this->countPlaceHolder => $this->currentFileCount]);
        }

        return $fileName;
    }
1246179
private function getDirectoryPathByHash($filename)
    {
        //get 2 number
        $val1 = ord($filename[1]);
        $val2 = ord($filename[3]);

        //normalize to 99
        $val1 %= 99;
        $val2 %= 99;
        return $val1 . '/' . $val2 . '/';
    }
288103
private static function guessFromFileCommand(string $filename): string
    {
        $result = 'application/octet-stream';

        if (!self::isCommandAvailable('file')) {
            return $result;
        }

        $info = trim(shell_exec('file -bi '.escapeshellarg($filename)));

        return $info != '' ? $info : $result;
    }
478873
static function filenameWithoutExtension($filename) {
		$filename=self::filename($filename);
		if (preg_match('~(.*)\.(\w{1,10})$~',$filename,$parts)) {
			return $parts[1];
		}
		return $filename;
	}
703035
public static function getMediaTypeFromFilename(string $filename): string
    {
        $pathinfo = pathinfo(strtolower($filename));
        if (!isset($pathinfo['extension'])) {
            return 'application/octet-stream';
        }
        return self::$extensionToMediaType[$pathinfo['extension']] ?? 'application/octet-stream';
    }
1216823
private static function getClassName($filename)
    {
        $directoriesAndFilename = explode('/', $filename);
        $filename = array_pop($directoriesAndFilename);
        $nameAndExtension = explode('.', $filename);
        $className = array_shift($nameAndExtension);

        return $className;
    }
795789
public function setFileName($filename)
  {
    $a = explode('.', $filename);

    $this->file_name      = $filename;
    $this->file_extension = count($a) >= 2 ? array_pop($a) : false;

    return $this;
  }
368907
public static function getSafeFileName($fileName, $directory = null) {
        $lastDot = strrpos($fileName, '.');
        $file = $lastDot ? substr($fileName, 0, $lastDot) : $fileName;
        $ending = $lastDot ? substr($fileName, $lastDot+1) : '';
        $safeName = self::removeSpecChars($file);
        $safeEnding = empty($ending)
            ? ''
            : '.'.self::removeSpecChars($ending);
        
        if ($directory != null && file_exists($directory.$safeName.$safeEnding)) {
            $count = 1;
            while (file_exists($directory.$safeName.'_'.$count.$safeEnding)) {
                $count++;
            }
            $safeName = $safeName.'_'.$count;
        } 
        
        return $safeName.$safeEnding;
    }