You are here

public static function Utils::getFreeFileName in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7

2 calls to Utils::getFreeFileName()
AFile::setFreeFileName in vendor/edsdk/file-uploader-server-php/src/lib/file/AFile.php
URLDownloader::downloadURL in vendor/edsdk/file-uploader-server-php/src/lib/file/URLDownloader.php

File

vendor/edsdk/file-uploader-server-php/src/lib/file/Utils.php, line 28

Class

Utils

Namespace

EdSDK\FileUploaderServer\lib\file

Code

public static function getFreeFileName($dir, $defaultName, $alwaysWithIndex) {
  $i = $alwaysWithIndex ? 0 : -1;
  do {
    $i++;
    if ($i == 0) {
      $name = $defaultName;
    }
    else {
      $name = Utils::getNameWithoutExt($defaultName) . "_" . $i . (Utils::getExt($defaultName) != null ? "." . Utils::getExt($defaultName) : "");
    }
    $filePath = $dir . $name;
    $ok = !file_exists($filePath);
  } while (!$ok);
  return $name;
}