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

int gp_filesystem_append ( CameraFilesystem fs,
const char *  folder,
const char *  filename,
GPContext context 

Append a file to a folder in a filesystem.

fs a CameraFilesystem
folder the folder where to put the file in
filename filename of the file
context a GPContext
Tells the fs that there is a file called filename in folder called folder. Usually camera drivers will call this function after capturing an image in order to tell the fs about the new file. A front-end should not use this function.

a gphoto2 error code.

Definition at line 715 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);

Generated by  Doxygen 1.6.0   Back to index