Logo Search packages:      
Sourcecode: libgphoto2 version File versions

int gp_file_save ( CameraFile file,
const char *  filename 

file a CameraFile
a gphoto2 error code.

Definition at line 238 of file gphoto2-file.c.

References CHECK_NULL.

      FILE *fp;
      struct utimbuf u;

      CHECK_NULL (file && filename);

      if (!(fp = fopen (filename, "wb")))
            return (GP_ERROR);

      if (fwrite (file->data, (size_t)sizeof(char), (size_t)file->size, fp) != (size_t)file->size) {
            gp_log (GP_LOG_ERROR, "libgphoto2",
                  "Not enough space on device in "
                  "order to save '%s'.", filename);
            unlink (filename);
            return (GP_ERROR);

      fclose (fp);

      if (file->mtime) {
            u.actime = file->mtime;
            u.modtime = file->mtime;
            utime (filename, &u);

      return (GP_OK);

Generated by  Doxygen 1.6.0   Back to index