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.

Parameters:
fsa CameraFilesystem
folderthe folder where to put the file in
filenamefilename of the file
contexta 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.

Returns:
a gphoto2 error code.

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

References GP_ERROR_FILE_EXISTS, GP_ERROR_NO_MEMORY, gp_log(), GP_LOG_DEBUG, and GP_OK.

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);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index