生成单次有效签名函数（用于删除和更新指定fileId资源，使用一次即失效）.

@param string $bucketName 文件所在bucket
@param string $path

@return string 签名
173133
public static function appSign_once($path, $bucketName)
    {
        $appId = Conf::getAppId();
        $secretId = Conf::getSecretId();
        $secretKey = Conf::getSecretKey();

        if (preg_match('/^\//', $path) == 0) {
            $path = '/'.$path;
        }
        $fileId = '/'.$appId.'/'.$bucketName.$path;

        if (empty($secretId) || empty($secretKey) || empty($appId)) {
            return self::AUTH_SECRET_ID_KEY_ERROR;
        }

        return self::appSignBase($appId, $secretId, $secretKey, 0, $fileId, $bucketName);
    }
264140
protected static function createGcsFilename($bucket, $object = null) {
    if (!isset($object)) {
      $object = "";
    }

    // Strip leading "/" for $object.
    if (StringUtil::startsWith($object, "/")) {
      $object = substr($object, 1);
    }

    return CloudStorageTools::getFilename($bucket, $object);
  }
473219
public function rename($path)
    {
        // This implementation supersedes the Flysystem's one. Indeed, while using connectors
        // such as the Amazon S3 (v3) connector, rename on directories does not work. A custom
        // implementation is then needed.
        $contents = $this->getFileSystem()->listContents($this->getPrefix(), true);

        // Filter files only.
        $filePaths = [];
        foreach ($contents as $content) {
            if ($content['type'] === 'file') {
                $filePaths[]= [
                    'source' => $content['path'],
                    'destination' => str_replace($this->getPrefix(), $path, $content['path'])];
            }
        }

        foreach ($filePaths as $renaming) {
            try {
                if ($this->getFileSystem()->rename($renaming['source'], $renaming['destination']) === false) {
                    throw new \common_exception_FileSystemError("Unable to rename '" . $this->getPrefix() . "' into '${path}'.");
                }
            } catch (FileExistsException $e) {
                throw new \common_exception_FileSystemError("Unable to rename '" . $this->getPrefix() . "' into '${path}'. File already exists.");
            }
        }

        if (!$this->deleteSelf()) {
            throw new \common_exception_FileSystemError("Could not finalize renaming of '" . $this->getPrefix() . "' into '${path}'.");
        }

        return true;
    }
1276050
public static function getFilename($path)
    {
        $name = pathinfo($path, PATHINFO_FILENAME);

        $ext = pathinfo($path, PATHINFO_EXTENSION);

        if ($ext) {
            $name .= '.' . $ext;
        }

        return $name;
    }
391779
public function rename($path, $newpath)
    {
        $pathinfo = pathinfo($path);
        if ($pathinfo['dirname'] != '.') {
            $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename'];
        } else {
            $path_remote = $pathinfo['filename'];
        }

        $newpathinfo = pathinfo($newpath);
        if ($newpathinfo['dirname'] != '.') {
            $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename'];
        } else {
            $newpath_remote = $newpathinfo['filename'];
        }

        $result = Uploader::rename($path_remote, $newpath_remote);

        return $result['public_id'] == $newpathinfo['filename'];
    }
518969
public function getSignedDownloadUrl($path, $expires = 3600, $host_name = '', $use_ssl = false)
    {
        $object = $this->applyPathPrefix($path);
        $url = $this->client->signUrl($this->bucket, $object, $expires);

        if (! empty($host_name) || $use_ssl) {
            $parse_url = parse_url($url);
            if (! empty($host_name)) {
                $parse_url['host'] = $this->bucket.'.'.$host_name;
            }
            if ($use_ssl) {
                $parse_url['scheme'] = 'https';
            }

            $url = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '')
                   .(
                   isset($parse_url['user']) ?
                       $parse_url['user'].(isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').'@'
                       : ''
                   )
                   .(isset($parse_url['host']) ? $parse_url['host'] : '')
                   .(isset($parse_url['port']) ? ':'.$parse_url['port'] : '')
                   .(isset($parse_url['path']) ? $parse_url['path'] : '')
                   .(isset($parse_url['query']) ? '?'.$parse_url['query'] : '');
        }

        return $url;
    }
1311726
protected function _dirname($path) {
	
		$newpath =  preg_replace("/\/$/", "", $path);
		$dn = substr($path, 0, strrpos($newpath, '/')) ;
		
		if (substr($dn, 0, 1) != '/') {
		 $dn = "/$dn";
		}
		
		return $dn;
	}
678392
public static function splitNameFromPath($path)
    {
        $name = static::nameFromPath($path);
        $path = static::trimFileName($path);

        return [$path, $name];
    }
419550
public static function getFileNameFromPath($path)
    {
        $matches = [];
        $pattern = sprintf('|([^\%s.]+\.[A-Za-z0-9.]+)$|', DIRECTORY_SEPARATOR);

        if ((bool)preg_match($pattern, $path, $matches)) {
            return $matches[1];
        }

        return '';
    }
707789
public static function randomFilename($extension, $path) {

		// fixes path if not containing trailing slash
		self::fixTrailingSlash($path);

		$pathParts = pathinfo($extension);
		$ext = isset($pathParts['extension']) ? $pathParts['extension'] : $extension;
		
		$newName	= substr(md5(microtime(TRUE)),0,10);
		$filename	= $newName . '.' . $ext;

		// in case exists, create a new name
		while (file_exists($path . $filename)) {
			$newName = substr(md5(microtime(TRUE)),0,10);
			$filename = $newName . '.' . $ext;
		}

		return $filename;

	}
111611
public static function incrementFilename($path){
		$i = 1;
		$dir = dirname($path);
		$filename = basename($path);
		if(preg_match('#^(\d+)-(.*)$#',basename($path),$matches)){
			$i = (int) $matches[1];
			$filename = $matches[2];
		}
		do {
			$target = rtrim($dir,'/').'/'.self::cleanFilename($i++.'-'.$filename);
		} while(file_exists($target));
		return $target;
	}
965814
public static function uniqueFilename($filename, $path) {
	
		// fixes path if not containing trailing slash
		self::fixTrailingSlash($path);
	
		if (file_exists($path . $filename)) {
			$dot  = strrpos($filename,'.');
			$ext  = substr($filename,$dot);
			$name = substr($filename,0,$dot);
			$hash = substr(md5(time()),0,6);
			$filename = $name . '-' . $hash . $ext;
		}
	
		return $filename;
	
	}
949067
public static function createNonreusableSignature($bucket, $filepath) {
        $appId = Conf::APP_ID;
        $secretId = Conf::SECRET_ID;
        $secretKey = Conf::SECRET_KEY;

        if (empty($appId) || empty($secretId) || empty($secretKey)) {
            return self::AUTH_SECRET_ID_KEY_ERROR;
        }

        if (preg_match('/^\//', $filepath) == 0) {
            $filepath = '/' . $filepath;
        }
        $fileId = '/' . $appId . '/' . $bucket . $filepath;

        return self::createSignature($appId, $secretId, $secretKey, 0, $bucket, $fileId);
    }
575326
private function __dnsBucketName($bucket)
	{
		if (strlen($bucket) > 63 || preg_match("/[^a-z0-9\.-]/", $bucket) > 0) return false;
		if (S3::$useSSL && strstr($bucket, '.') !== false) return false;
		if (strstr($bucket, '-.') !== false) return false;
		if (strstr($bucket, '..') !== false) return false;
		if (!preg_match("/^[0-9a-z]/", $bucket)) return false;
		if (!preg_match("/[0-9a-z]$/", $bucket)) return false;
		return true;
	}
664897
public function getFileName($path, $filename)
	{
		if (file_exists("$path/$filename")) {
			$filename = Nette\Utils\Random::generate() . '_' . $filename;
			$filename = $this->getFileName($path, $filename);
		} else {
			$filename;
		}

		return $filename;
	}
556400
public static function cleanFilePathname($path) {
		if (UString::isNotNull ( $path )) {
			if (\DS === "/")
				$path = \str_replace ( "\\", \DS, $path );
			else
				$path = \str_replace ( "/", \DS, $path );
			$path = \str_replace ( \DS . \DS, \DS, $path );
		}
		return $path;
	}
419545
public static function delFile($bucket, $path) {
        if (empty($bucket) || empty($path)) {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'path is empty');
        }

        $path = self::normalizerPath($path);

        return self::delBase($bucket, $path);
    }