/**
  * Set unique name for folder
  *
  * @param Folder $folder
  * @return Folder
  */
 public function folder(Folder $folder)
 {
     if (FileSystem::exists($folder->fullPath())) {
         $original_name = $folder->name();
         $folder->setName($original_name . '-1');
         for ($i = 2; FileSystem::exists($folder->fullPath()); $i++) {
             $folder->setName($original_name . '-' . $i);
         }
     }
     return $folder;
 }
 /**
  * Delete folder from file system
  *
  * @param string $folder_name The folder name to be deleted
  *
  * @return bool
  */
 public function deleteFolder($folder_name)
 {
     $folder = $this->folder->setName($folder_name);
     return $this->sys->deleteFolder($folder);
 }
 /**
  * @param Folder $folder
  *
  * @return bool
  *
  * @throws FileManagerException
  */
 public function deleteFolder(Folder $folder)
 {
     $path = $folder->fullPath();
     if (!FileSystem::exists($path)) {
         throw new FileManagerException($this, 'err_folder_not_found');
     }
     if (!Perms::canDelete($path)) {
         throw new FileManagerException($this, 'err_folder_delete_perm');
     }
     return FileSystem::deleteDirectory($path);
 }