You are here

private function FMDiskFileSystem::renameFileOrDir in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2

2 calls to FMDiskFileSystem::renameFileOrDir()
FMDiskFileSystem::renameDir in src/Flmngr/FlmngrServer/fs/FMDiskFileSystem.php
Renames a directory.
FMDiskFileSystem::renameFile in src/Flmngr/FlmngrServer/fs/FMDiskFileSystem.php
Renames a file.

File

src/Flmngr/FlmngrServer/fs/FMDiskFileSystem.php, line 145

Class

FMDiskFileSystem
Implements file system interface. Provides an interface to access file system (local disc FS). This is the correct module to replace if you want to implement some custom file system support (i. e. network file system like Amazon S3).

Namespace

Drupal\n1ed\Flmngr\FlmngrServer\fs

Code

private function renameFileOrDir($path, $newName) {
  if (strpos($newName, "..") !== FALSE || strpos($newName, "/") !== FALSE) {
    throw new MessageException(FMMessage::createMessage(FMMessage::FM_DIR_NAME_CONTAINS_INVALID_SYMBOLS));
  }
  $fullPath = $this
    ->getAbsolutePath($path);
  $i = strrpos($fullPath, "/");
  $fullPathDst = substr($fullPath, 0, $i + 1) . $newName;
  if (is_file($fullPathDst)) {
    throw new MessageException(Message::createMessage(Message::FILE_ALREADY_EXISTS, $newName));
  }
  $res = rename($fullPath, $fullPathDst);
  if ($res === FALSE) {
    throw new MessageException(FMMessage::createMessage(FMMessage::FM_UNABLE_TO_RENAME));
  }
}