~ubuntu-branches/ubuntu/trusty/gimp/trusty

« back to all changes in this revision

Viewing changes to libgimpconfig/gimpconfigwriter.c

  • Committer: Bazaar Package Importer
  • Author(s): Ari Pollak
  • Date: 2009-08-14 09:57:17 UTC
  • mto: (1.1.21 upstream) (0.1.5 squeeze)
  • mto: This revision was merged to the branch mainline in revision 48.
  • Revision ID: james.westby@ubuntu.com-20090814095717-37dh2xqy5t0rurpk
ImportĀ upstreamĀ versionĀ 2.6.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
664
664
      return FALSE;
665
665
    }
666
666
 
 
667
#ifdef HAVE_FSYNC
 
668
  /* If the final destination exists, we want to sync the newly written
 
669
   * file to ensure the data is on disk when we rename over the destination.
 
670
   * otherwise if we get a system crash we can lose both the new and the
 
671
   * old file on some filesystems. (I.E. those that don't guarantee the
 
672
   * data is written to the disk before the metadata.)
 
673
   */
 
674
  if (writer->tmpname && g_file_test (writer->filename, G_FILE_TEST_EXISTS))
 
675
    {
 
676
      if (fsync (writer->fd) != 0)
 
677
        {
 
678
          g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,
 
679
                       _("Error writing to temporary file for '%s': %s\n"
 
680
                         "The original file has not been touched."),
 
681
                       gimp_filename_to_utf8 (writer->filename),
 
682
                       g_strerror (errno));
 
683
 
 
684
          close (writer->fd);
 
685
          g_unlink (writer->tmpname);
 
686
 
 
687
          return FALSE;
 
688
        }
 
689
    }
 
690
#endif
 
691
 
667
692
  if (close (writer->fd) != 0)
668
693
    {
669
694
      if (writer->tmpname)
700
725
 
701
726
  if (writer->tmpname)
702
727
    {
703
 
#ifdef G_OS_WIN32
704
 
      /* win32 rename can't overwrite */
705
 
      g_unlink (writer->filename);
706
 
#endif
707
 
 
708
728
      if (g_rename (writer->tmpname, writer->filename) == -1)
709
729
        {
710
730
          g_set_error (error, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_WRITE,