Logo Search packages:      
Sourcecode: libgphoto2 version File versions  Download package

int gp_filesystem_remove_dir ( CameraFilesystem fs,
const char *  folder,
const char *  name,
GPContext context 
)

Remove a subfolder from within a folder.

Parameters:
fs a CameraFilesystem
folder the folder in which the directory should be created
name the name of the directory to be created
context a GPContext
Removes a directory called name from the given folder.

Returns:
a gphoto2 error code

Definition at line 1195 of file gphoto2-filesys.c.

References CHECK_NULL, _CameraFilesystem::folder_data, GP_ERROR_DIRECTORY_EXISTS, GP_ERROR_DIRECTORY_NOT_FOUND, GP_ERROR_FILE_EXISTS, GP_ERROR_NOT_SUPPORTED, GP_OK, _CameraFilesystem::remove_dir_func, and _CameraFilesystem::rootfolder.

Referenced by gp_camera_folder_remove_dir().

{
      CameraFilesystemFolder *f;
      CameraFilesystemFolder **prev;

      CHECK_NULL (fs && folder && name);
      CC (context);
      CA (folder, context);

      if (!fs->remove_dir_func)
            return (GP_ERROR_NOT_SUPPORTED);

      /*
       * Make sure there are neither files nor folders in the folder
       * that is to be removed.
       */
      f = lookup_folder (fs, fs->rootfolder, folder, context);
      if (!f) return (GP_ERROR_DIRECTORY_NOT_FOUND);
      prev = &(f->folders);
      while (*prev) {
            if (!strcmp (name, (*prev)->name))
                  break;
            prev = &((*prev)->next);
      }
      if (!*prev) return (GP_ERROR_DIRECTORY_NOT_FOUND);

      if ((*prev)->folders) {
            gp_context_error (context, _("There are still subfolders in "
                  "folder '%s/%s' that you are trying to remove."), folder, name);
            return (GP_ERROR_DIRECTORY_EXISTS);
      }
      if ((*prev)->files) {
            gp_context_error (context, _("There are still files in "
                  "folder '%s/%s' that you are trying to remove."), folder,name);
            return (GP_ERROR_FILE_EXISTS);
      }

      /* Remove the directory */
      CR (fs->remove_dir_func (fs, folder, name, fs->folder_data, context));
      CR (delete_folder (fs, prev));
      return (GP_OK);
}


Generated by  Doxygen 1.6.0   Back to index