public static function Utils::getFreeFileName in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Gets free file name.
2 calls to Utils::getFreeFileName()
- AFile::setFreeFileName in src/
Flmngr/ FileUploaderServer/ lib/ file/ AFile.php - Generates and sets free file name for this file.
- URLDownloader::downloadUrl in src/
Flmngr/ FileUploaderServer/ lib/ file/ URLDownloader.php - Downloads URL.
File
- src/
Flmngr/ FileUploaderServer/ lib/ file/ Utils.php, line 35
Class
- Utils
- Utilites for uploader.
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\lib\fileCode
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;
}