[gegl] gegl: Warn when open() fails



commit 095613374510d3bd1b91667db09b8fdc7bd02681
Author: Martin Nordholts <martinn src gnome org>
Date:   Tue May 3 20:37:09 2011 +0200

    gegl: Warn when open() fails

 gegl/buffer/gegl-buffer-save.c       |    3 +++
 gegl/buffer/gegl-tile-backend-file.c |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-save.c b/gegl/buffer/gegl-buffer-save.c
index 179a712..1b73fa8 100644
--- a/gegl/buffer/gegl-buffer-save.c
+++ b/gegl/buffer/gegl-buffer-save.c
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include <glib-object.h>
 
@@ -224,6 +225,8 @@ gegl_buffer_save (GeglBuffer          *buffer,
 
   info->path = g_strdup (path);
   info->o    = open (info->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+  if (info->o == -1)
+    g_warning ("%s: Could not open '%s': %s", G_STRFUNC, info->path, g_strerror(errno));
   tile_width  = buffer->tile_storage->tile_width;
   tile_height = buffer->tile_storage->tile_height;
   g_object_get (buffer, "px-size", &bpp, NULL);
diff --git a/gegl/buffer/gegl-tile-backend-file.c b/gegl/buffer/gegl-tile-backend-file.c
index e5748be..5ffbf39 100644
--- a/gegl/buffer/gegl-tile-backend-file.c
+++ b/gegl/buffer/gegl-tile-backend-file.c
@@ -868,6 +868,8 @@ gegl_tile_backend_file_constructor (GType                  type,
                         self);
 
       self->o = open (self->path, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+      if (self->o == -1)
+        g_warning ("%s: Could not open '%s': %s", G_STRFUNC, self->path, g_strerror (errno));
       self->i = dup (self->o);
 
       self->header = gegl_buffer_read_header (self->i, &offset)->header;
@@ -920,6 +922,8 @@ gegl_tile_backend_file_ensure_exist (GeglTileBackendFile *self)
       GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "creating swapfile  %s", self->path);
 
       self->o = open (self->path, O_RDWR|O_CREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+      if (self->o == -1)
+        g_warning ("%s: Could not open '%s': %s", G_STRFUNC, self->path, g_strerror (errno));
 
       self->next_pre_alloc = 256;  /* reserved space for header */
       self->total          = 256;  /* reserved space for header */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]