Ejemplo n.º 1
0
 /**
  * @param string $container
  * @param string $dest_path
  * @param        $src_container
  * @param string $src_path
  * @param bool   $check_exist
  *
  * @throws NotFoundException
  * @throws BadRequestException
  * @return void
  */
 public function copyFolder($container, $dest_path, $src_container, $src_path, $check_exist = false)
 {
     // does this file already exist?
     if (!$this->folderExists($src_container, $src_path)) {
         throw new NotFoundException("Folder '{$src_path}' does not exist.");
     }
     if ($this->folderExists($container, $dest_path)) {
         if ($check_exist) {
             throw new BadRequestException("Folder '{$dest_path}' already exists.");
         }
     }
     // does this file's parent folder exist?
     $parent = FileUtilities::getParentFolder($dest_path);
     if (!empty($parent) && !$this->folderExists($container, $parent)) {
         throw new NotFoundException("Folder '{$parent}' does not exist.");
     }
     // create the folder
     $this->checkContainerForWrite($container);
     // need to be able to write to storage
     FileUtilities::copyTree(static::addContainerToName($src_container, $src_path), static::addContainerToName($container, $dest_path));
 }