You are here

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

Copies files.

Overrides FMDiskFileSystemInterface::copyFiles

File

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

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

function copyFiles($filesPaths, $newPath) {
  for ($i = 0; $i < count($filesPaths); $i++) {
    $fullPathSrc = $this
      ->getAbsolutePath($filesPaths[$i]);
    $index = strrpos($fullPathSrc, "/");
    $name = $index === FALSE ? $fullPathSrc : substr($fullPathSrc, $index + 1);
    $fullPathDst = $this
      ->getAbsolutePath($newPath) . "/" . $name;
    $res = copy($fullPathSrc, $fullPathDst);
    if ($res === FALSE) {
      throw new MessageException(FMMessage::createMessage(FMMessage::FM_ERROR_ON_COPYING_FILES));
    }
  }
}