Create unique file name in required dir

@param  String  file name
@param  String  parent dir hash
@param  String  glue
@return String
178425
function(prefix, phash, glue) {
		var i = 0, ext = '', p, name;
		
		prefix = this.i18n(false, prefix);
		phash = phash || this.cwd().hash;
		glue = (typeof glue === 'undefined')? ' ' : glue;

		if (p = prefix.match(/^(.+)(\.[^.]+)$/)) {
			ext    = p[2];
			prefix = p[1];
		}
		
		name   = prefix+ext;
		
		if (!this.fileByName(name, phash)) {
			return name;
		}
		while (i < 10000) {
			name = prefix + glue + (++i) + ext;
			if (!this.fileByName(name, phash)) {
				return name;
			}
		}
		return prefix + Math.random() + ext;
	}
22337
private function getUniqueFileName(string $folder, string $fileName, int $counter = 0): string
    {
        $newFileName = $fileName;

        if ($counter > 0) {
            $fileNameParts = explode('.', $fileName, 2);
            $newFileName = $fileNameParts[0] . '-' . $counter;

            if (isset($fileNameParts[1])) {
                $newFileName .= '.' . $fileNameParts[1];
            }
        }

        $filePath = $this->getPathByFolderAndFileName($folder, $newFileName);

        $this->logger->debug('Check FilePath: ' . $filePath);

        if (!$this->filesystem->exists($filePath)) {
            return $newFileName;
        }

        ++$counter;

        return $this->getUniqueFileName($folder, $fileName, $counter);
    }
31049
public void ensureUniqueName(
        final String parentFolder,
        String newName,
        final I_CmsSimpleCallback<String> callback) {

        // using lower case folder names
        final String lowerCaseName = newName.toLowerCase();
        CmsRpcAction<String> action = new CmsRpcAction<String>() {

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#execute()
             */
            @Override
            public void execute() {

                start(0, false);
                CmsCoreProvider.getService().getUniqueFileName(parentFolder, lowerCaseName, this);
            }

            /**
             * @see org.opencms.gwt.client.rpc.CmsRpcAction#onResponse(java.lang.Object)
             */
            @Override
            protected void onResponse(String result) {

                stop(false);
                callback.execute(result);
            }

        };
        action.execute();
    }
701163
function removeFileNameHash( fileName ) {
  return fileName
    .replace( appBuild, '' )
    .replace( /\/?(.*)(\.\w+)(\.js|\.css)/, ( match_, p1, p2_, p3 ) => p1 + p3 );
}
578929
protected function constructFileName($name)
    {
        list($usec, $sec) = explode(' ', microtime());

        $usec = substr($usec, 2, 6);

        return date('Y_m_d_His', $sec).'_'.$usec.'_'.$name;
    }
158944
def split_filename(name):
    
    parts = hashed_filename_re.match(name).groupdict()
    return (parts['name'] or '', parts['hash'] or '', parts['ext'] or '')
742528
function fileScope(filename) {
    filename = path.resolve('', filename || '');
    var result = scopes[filename];
    if (!result) {
      result = create({
        clean: clean,
        removeList: removeList,
        excludeList: excludeList,
        rootScope: rootScope,
        filename: filename,
        argv: argv,
        scopes: scopes,
        processors: processors,
        variants: variants,
        cacheKeys: cacheKeys,
        tags: tags
      });
    }
    return result;
  }
483903
public static String uniquePath(String name, String ext) throws IOException
    {
        File file = File.createTempFile(name, ext);
        String path = file.getAbsolutePath();
        file.delete();

        return path;
    }
32840
def new_filename(original_filename, new_locale):
    """"""
    orig_file = Path(original_filename)
    new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name
    return new_file.abspath()
22154
public function getFileName($source_name, $type, $tmp_name, $index, $content_range, FileUpload $upload)
    {
        $this->filesystem = $upload->getFileSystem();
        $this->pathresolver = $upload->getPathResolver();

        $source_name = $this->getSluggedFileName($source_name);
        $uniqueFileName = $this->getUniqueFilename($source_name, $type, $index, $content_range);

        return $this->getSluggedFileName($uniqueFileName);
    }
71443
@SuppressWarnings("unused")
    private Map<String, String> hashFiles(String... fileNames) {
        Map<String, String> hashes = new HashMap<String, String>();
        for (int i = 0; i < fileNames.length; i++) {
            String hash = hashURL(fileNames[i]);
            hashes.put(fileNames[i], hash);
        }
        return hashes;
    }
685904
function fileName(file) {
  let prefix = null
  let reference = null

  if (isPathSubDirOf(file, PROJECT_DIR)) {
    // Assets from the target project.
    prefix = []
    reference = PROJECT_DIR
  } else if (isPathSubDirOf(file, TOOLBOX_DIR)) {
    // Assets from the Toolbox.
    prefix = ['__borela__']
    reference = TOOLBOX_DIR
  }

  const RELATIVE = relative(reference, file)
  let nodes = RELATIVE.split(sep)

  if (nodes[0] === 'src')
    nodes.shift()

  if (prefix.length > 0)
    nodes = [...prefix, ...nodes]

  return `${nodes.join('/')}?[sha512:hash:base64:8]`
}
938443
function createResourceName(share, directory, file, forSAS) {
  var encode = function(name) {
    if (name && !forSAS) {
      name = encodeURIComponent(name);
      name = name.replace(/%2F/g, '/');
      name = name.replace(/%5C/g, '/');
      name = name.replace(/\+/g, '%20');
    }
    return name;
  };

  var name = share;

  if (directory) {
    // if directory does not start with '/', add it
    if (directory[0] !== '/') {
      name += ('/');
    }

    name += encode(directory);
  } 

  if (file) {
    // if the current path does not end with '/', add it
    if (name[name.length - 1] !== '/') {
      name += ('/');
    }
    
    name += encode(file);
  }

  return path.normalize(name).replace(/\\/g, '/');
}
89471
private static File getUserDirectory(final String prefix, final String suffix, final File parent) {
        final String dirname = formatDirName(prefix, suffix);
        return new File(parent, dirname);
    }
337193
protected function getFileName(string $namespace, string $hash): string
    {
        $fileName = implode(DIRECTORY_SEPARATOR, [
            $this->directory,
            $namespace,
            substr($hash, 0, 2),
            $hash
        ]);
        return $fileName;
    }
776892
protected String createFile(String dir, String fileName, byte[] content) {
        String baseName = FilenameUtils.getBaseName(fileName);
        String ext = FilenameUtils.getExtension(fileName);
        String downloadedFile = FileUtil.saveToFile(dir + baseName, ext, content);
        return linkToFile(downloadedFile);
    }
200218
function make_filename($filename)
    {
        // Check if it's an absolute or relative path.
        if (pia_substr($filename, 0, 1) != '/') {
            $filename = $this->root . '/' . $filename;
        }

        if (!file_exists($filename)) {
            die("Template->make_filename(): Erreur - Le fichier $filename est inexistant");
        }
        return $filename;
    }