source/Core/UtilsFile.php
protected function _getUniqueFileName($sFilePath, $sFileName, $sFileExt, $sSufix = "", $blUnique = true)
    {
        $sFilePath = $this->normalizeDir($sFilePath);
        $iFileCounter = 0;
        $sTempFileName = $sFileName;
        $oStr = getStr();

        //file exists ?
        while ($blUnique && file_exists($sFilePath . "/" . $sFileName . $sSufix . "." . $sFileExt)) {
            $iFileCounter++;

            //removing "(any digit)" from file name end
            $sTempFileName = $oStr->preg_replace("/\(" . $iFileCounter . "\)/", "", $sTempFileName);

            $sFileName = $sTempFileName . "($iFileCounter)";
        }

        return $sFileName . $sSufix . "." . $sFileExt;
    }
protected function _getUniqueFileName($sFilePath, $sFileName, $sFileExt, $sSufix = "", $blUnique = true)
    {
        $sFilePath = $this->normalizeDir($sFilePath);
        $iFileCounter = 0;
        $sTempFileName = $sFileName;
        $oStr = getStr();

        //file exists ?
        while ($blUnique && file_exists($sFilePath . "/" . $sFileName . $sSufix . "." . $sFileExt)) {
            $iFileCounter++;

            //removing "(any digit)" from file name end
            $sTempFileName = $oStr->preg_replace("/\(" . $iFileCounter . "\)/", "", $sTempFileName);

            $sFileName = $sTempFileName . "($iFileCounter)";
        }

        return $sFileName . $sSufix . "." . $sFileExt;
    }
protected function _getUniqueFileName ( $ sFilePath , $ sFileName , $ sFileExt , $ sSufix = "" , $ blUnique = true ) { $ sFilePath = $ this -> normalizeDir ( $ sFilePath ) ; $ iFileCounter = 0 ; $ sTempFileName = $ sFileName ; $ oStr = getStr ( ) ; //file exists ? while ( $ blUnique && file_exists ( $ sFilePath . "/" . $ sFileName . $ sSufix . "." . $ sFileExt ) ) { $ iFileCounter ++ ; //removing "(any digit)" from file name end $ sTempFileName = $ oStr -> preg_replace ( "/\(" . $ iFileCounter . "\)/" , "" , $ sTempFileName ) ; $ sFileName = $ sTempFileName . "($iFileCounter)" ; } return $ sFileName . $ sSufix . "." . $ sFileExt ; }
Checks if file with same name does not exist, if exists - addes number prefix
to file name Returns unique file name.

@param string $sFilePath file storage path/folder (e.g. /htdocs/out/img/)
@param string $sFileName name of file (e.g. picture1)
@param string $sFileExt  file extension (e.g. gif)
@param string $sSufix    file name sufix (e.g. _ico)
@param bool   $blUnique  TRUE - generates unique file name, FALSE - just glues given parts of file name

@return string
Checks if file with same name does not exist if exists - addes number prefix to file name Returns unique file name .