From 0b82cc7a34271a145a45ff7f296304e19a9315cc Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Fri, 14 Mar 2003 17:19:25 +0000 Subject: use access() like camel 2003-03-14 Mike Kestner * gal/util/e-util.c (e_mkdir_hier): use access() like camel 2003-03-14 Mike Kestner * gal-view-collection.c (gal_view_collection_load): check failure on e_create_directory call and warn. * gal-view-instance.c (save_current_view): check for failure and warn. svn path=/trunk/; revision=20291 --- e-util/e-util.c | 7 ++----- widgets/menus/gal-view-collection.c | 7 +++++-- widgets/menus/gal-view-instance.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/e-util/e-util.c b/e-util/e-util.c index 6c50331011..b830f654ee 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -275,11 +275,8 @@ e_mkdir_hier(const char *path, mode_t mode) p = strchr (p + 1, '/'); if (p) *p = '\0'; - if (mkdir (copy, mode) == -1) { - switch (errno) { - case EEXIST: - break; - default: + if (access (copy, F_OK) == -1) { + if (mkdir (copy, mode) == -1) { g_free (copy); return -1; } diff --git a/widgets/menus/gal-view-collection.c b/widgets/menus/gal-view-collection.c index b7a571132e..87ac878b83 100644 --- a/widgets/menus/gal-view-collection.c +++ b/widgets/menus/gal-view-collection.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -469,7 +470,8 @@ gal_view_collection_load (GalViewCollection *collection) g_return_if_fail (collection->system_dir != NULL); g_return_if_fail (!collection->loaded); - e_create_directory(collection->local_dir); + if ((e_create_directory(collection->local_dir) == -1) && (errno != EEXIST)) + g_warning ("Unable to create dir %s: %s", collection->local_dir, g_strerror(errno)); load_single_dir(collection, collection->local_dir, TRUE); load_single_dir(collection, collection->system_dir, FALSE); @@ -537,7 +539,8 @@ gal_view_collection_save (GalViewCollection *collection) e_xml_set_string_prop_by_name(child, "type", item->type); } filename = g_concat_dir_and_file(collection->local_dir, "galview.xml"); - e_xml_save_file (filename, doc); + if (e_xml_save_file (filename, doc) == -1) + g_warning ("Unable to save view to %s - %s", filename, g_strerror(errno)); xmlFreeDoc(doc); g_free(filename); } diff --git a/widgets/menus/gal-view-instance.c b/widgets/menus/gal-view-instance.c index cda202f552..c26eadb5df 100644 --- a/widgets/menus/gal-view-instance.c +++ b/widgets/menus/gal-view-instance.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -92,7 +93,8 @@ save_current_view (GalViewInstance *instance) if (instance->current_type) e_xml_set_string_prop_by_name (root, "current_view_type", instance->current_type); - e_xml_save_file (instance->current_view_filename, doc); + if (e_xml_save_file (instance->current_view_filename, doc) == -1) + g_warning ("Unable to save view to %s - %s", instance->current_view_filename, g_strerror(errno)); xmlFreeDoc(doc); } -- cgit v1.2.3