You are here

private function FileUploadedQuick::checkFileNameExistence in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

1 call to FileUploadedQuick::checkFileNameExistence()
FileUploadedQuick::__construct in src/Flmngr/FileUploaderServer/lib/file/FileUploadedQuick.php
Creates a File instance.

File

src/Flmngr/FileUploaderServer/lib/file/FileUploadedQuick.php, line 40

Class

FileUploadedQuick

Namespace

Drupal\n1ed\Flmngr\FileUploaderServer\lib\file

Code

private function checkFileNameExistence() {
  function file_newname($path, $filename) {
    if ($pos = strrpos($filename, '.')) {
      $name = substr($filename, 0, $pos);
      $ext = substr($filename, $pos);
    }
    else {
      $name = $filename;
    }
    $newpath = $path . '/' . $filename;
    $newname = $filename;
    $counter = 0;
    while (file_exists($newpath)) {
      $newname = $name . '_' . $counter . $ext;
      $newpath = $path . '/' . $newname;
      $counter++;
    }
    return $newname;
  }
  return file_newname($this->dir, $this->name);
}