Append a file to a folder in a filesystem.
Definition at line 721 of file gphoto2-filesys.c. References CHECK_MEM, CHECK_NULL, GP_ERROR_FILE_EXISTS, GP_ERROR_NO_MEMORY, gp_log(), GP_LOG_DEBUG, GP_OK, and _CameraFilesystem::rootfolder. Referenced by gp_filesystem_list_files(). { CameraFilesystemFile **new; CameraFilesystemFolder *f; CHECK_NULL (fs && folder); CC (context); CA (folder, context); gp_log (GP_LOG_DEBUG, "gphoto2-filesystem", "Append %s/%s to filesystem", folder, filename); /* Check folder for existence, if not, create it. */ f = lookup_folder (fs, fs->rootfolder, folder, context); if (!f) CR (append_folder (fs, folder, &f, context)); new = &f->files; while (*new) { if (!strcmp((*new)->name, filename)) break; new = &((*new)->next); } if (*new) { gp_context_error (context, _("Could not append '%s' to folder '%s' because " "this file already exists."), filename, folder); return (GP_ERROR_FILE_EXISTS); } CHECK_MEM ((*new) = calloc (sizeof (CameraFilesystemFile), 1)) (*new)->name = strdup (filename); if (!(*new)->name) { free (*new); *new = NULL; return (GP_ERROR_NO_MEMORY); } (*new)->info_dirty = 1; f->files_dirty = 0; return (GP_OK); }
|