Index: libgthumb/file-utils.h
===================================================================
--- libgthumb/file-utils.h	(revision 2390)
+++ libgthumb/file-utils.h	(working copy)
@@ -98,7 +98,7 @@
 gboolean            dir_remove_recursive          (const char       *uri);
 gboolean            local_dir_remove_recursive    (const char       *path);
 
-gboolean            ensure_dir_exists             (const char       *a_path,
+gboolean            ensure_dir_exists             (const char       *path,
 						   mode_t            mode);
 GList *             dir_list_filter_and_sort      (GList            *dir_list,
 						   gboolean          names_only,
Index: libgthumb/gfile-utils.c
===================================================================
--- libgthumb/gfile-utils.c	(revision 2390)
+++ libgthumb/gfile-utils.c	(working copy)
@@ -21,3 +21,156 @@
  */
 
 
+#include <glib.h>
+
+#include "gfile-utils.h"
+
+/* GFile to string */
+
+char *
+gfile_get_uri (GFile *file)
+{
+	return g_file_get_uri (file);
+}
+
+
+char *
+gfile_get_path (GFile *file)
+{
+	char  *escaped, *unescaped;
+
+	escaped = g_file_get_path (file);
+	unescaped = g_uri_unescape_string (escaped, NULL);
+	
+	g_free (escaped);
+	
+	return unescaped;
+}
+
+
+/* warning about a GFile */
+
+void 
+gfile_warning (const char *msg,
+	       GFile      *file,
+	       GError     *err)
+{
+	char *uri;
+	char *warning;
+	
+	uri = gfile_get_uri (file);
+	warning = g_strdup_printf ("%s: file %s: %s\n", msg, uri, err->message);
+	
+	g_warning (warning);
+	
+        g_free (uri);
+}
+
+
+/* File type */
+
+static gboolean
+gfile_is_filetype (GFile      *file,
+		   GFileType   file_type)
+{
+	gboolean   result = FALSE;
+	GFileInfo *info;
+	GError    *error = NULL;
+
+	if (! g_file_query_exists (file, NULL))
+		return FALSE;
+
+	info = g_file_query_info (file, 
+			          G_FILE_ATTRIBUTE_STANDARD_TYPE, 
+			          0, 
+			          NULL, 
+			          &error);
+	if (error == NULL) {
+		result = (g_file_info_get_file_type (info) == file_type);
+	}
+	else {
+		gfile_warning ("Failed to get file type", file, error);
+		g_error_free (error);
+	}
+
+	g_object_unref (info);
+
+	return result;
+}
+
+
+gboolean
+gfile_path_is_file (GFile *file)
+{
+	return gfile_is_filetype (file, G_FILE_TYPE_REGULAR);
+}
+
+
+gboolean
+gfile_path_is_dir (GFile *file)
+{
+	return gfile_is_filetype (file, G_FILE_TYPE_DIRECTORY);
+}
+
+
+/* Directory utils */
+
+static gboolean
+make_directory_tree (GFile    *dir,
+		     mode_t    mode,
+		     GError  **error)
+{
+	gboolean  success = TRUE;
+	GFile    *parent;
+
+	parent = g_file_get_parent (dir);
+	if (parent != NULL) {
+		success = make_directory_tree (parent, mode, error);
+		g_object_unref (parent);
+		if (! success)
+			return FALSE;
+	}
+
+	success = g_file_make_directory (dir, NULL, error);
+	if ((error != NULL) && (*error != NULL) && g_error_matches (*error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
+		g_clear_error (error);
+		success = TRUE;
+	}
+
+	if (success)
+		g_file_set_attribute_uint32 (dir,
+					     G_FILE_ATTRIBUTE_UNIX_MODE,
+					     mode,
+					     0,
+					     NULL,
+					     NULL);
+
+	return success;
+}
+
+
+gboolean
+gfile_ensure_dir_exists (GFile    *dir,
+			 mode_t    mode,
+			 GError  **error)
+{
+	GError *priv_error = NULL;
+
+	//FIXME: we should get rid of this test and fix the callers instead
+	if (dir == NULL)
+		return FALSE;
+
+	if (error == NULL)
+		error = &priv_error;
+
+	if (! make_directory_tree (dir, mode, error)) {
+		
+		gfile_warning ("could not create directory", dir, error);
+		if (priv_error != NULL)
+			g_clear_error (&priv_error);
+		
+		return FALSE;
+	}
+
+	return TRUE;
+}
Index: libgthumb/gfile-utils.h
===================================================================
--- libgthumb/gfile-utils.h	(revision 2390)
+++ libgthumb/gfile-utils.h	(working copy)
@@ -23,5 +23,29 @@
 #ifndef GFILE_UTILS_H
 #define GFILE_UTILS_H
 
-					       
+#include <gio/gio.h>
+
+/* GFile to string */
+
+char *        gfile_get_uri            (GFile *file);
+char *        gfile_get_path           (GFile *file);
+
+/* Warning */
+
+void          gfile_warning            (const char *msg,
+	                                GFile      *file,
+	                                GError     *err);
+/* File type */
+
+gboolean      gfile_path_is_file       (GFile *file);
+gboolean      gfile_path_is_dir        (GFile *file);
+
+
+/* Directory utils */
+
+gboolean      gfile_ensure_dir_exists  (GFile    *dir,
+			                mode_t    mode,
+			                GError  **error);
+
+
 #endif /* GFILE_UTILS_H */
Index: libgthumb/file-utils.c
===================================================================
--- libgthumb/file-utils.c	(revision 2390)
+++ libgthumb/file-utils.c	(working copy)
@@ -53,6 +53,7 @@
 #include "gthumb-error.h"
 #include "glib-utils.h"
 #include "gconf-utils.h"
+#include "gfile-utils.h"
 #include "file-utils.h"
 #include "file-data.h"
 #include "pixbuf-utils.h"
@@ -466,50 +467,25 @@
 
 
 gboolean
-ensure_dir_exists (const char *a_path,
+ensure_dir_exists (const char *path,
 		   mode_t      mode)
 {
-	char *path;
-	char *p;
-
-	if (! a_path)
+	GFile    *file;
+	gboolean  result;
+	char     *uri;
+	
+	if (path == NULL)
 		return FALSE;
-
-	if (path_is_dir (a_path))
-		return TRUE;
-
-	path = g_strdup (a_path);
+	
+	uri = add_scheme_if_absent (path);
+	file = g_file_new_for_uri (uri);
+	
+	result = gfile_ensure_dir_exists (file, mode, NULL);
+	
+	g_free (uri);
+	g_object_unref (file);
 
-	p = strstr (path, "://");
-	if (p == NULL)   /* Not a URI */
-		p = path;
-	else  /* Is a URI */
-		p = p + 3;  /* Move p past the :// */
-
-	while (*p != '\0') {
-		p++;
-		if ((*p == '/') || (*p == '\0')) {
-			gboolean end = TRUE;
-
-			if (*p != '\0') {
-				*p = '\0';
-				end = FALSE;
-			}
-
-			if (! path_is_dir (path)) {
-				if (!dir_make (path, mode)) {
-					g_warning ("directory creation failed: %s.", path);
-					g_free (path);
-					return FALSE;
-				}
-			}
-			if (! end) *p = '/';
-		}
-	}
-
-	g_free (path);
-
-	return TRUE;
+	return result;
 }
 
 
@@ -1091,50 +1067,42 @@
 gboolean
 path_is_file (const char *path)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	gboolean          is_file;
-
-	if (! path || ! *path)
+	GFile    *file;
+	gboolean  result;
+	char     *uri;
+	
+	if (path == NULL)
 		return FALSE;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (path,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	is_file = FALSE;
-	if (result == GNOME_VFS_OK)
-		is_file = (info->type == GNOME_VFS_FILE_TYPE_REGULAR);
+	
+	uri = add_scheme_if_absent (path);
+	file = g_file_new_for_uri (uri);
+	
+	result = gfile_path_is_file (file);
+	
+	g_free (uri);
+	g_object_unref (file);
 
-	gnome_vfs_file_info_unref (info);
-
-	return is_file;
+	return result;
 }
 
-
 gboolean
 path_is_dir (const char *path)
 {
-	GnomeVFSFileInfo *info;
-	GnomeVFSResult    result;
-	gboolean          is_dir;
-
-	if (! path || ! *path)
+	GFile    *file;
+	gboolean  result;
+	char     *uri;
+	
+	if (path == NULL)
 		return FALSE;
-
-	info = gnome_vfs_file_info_new ();
-	result = gnome_vfs_get_file_info (path,
-					  info,
-					  (GNOME_VFS_FILE_INFO_DEFAULT
-					   | GNOME_VFS_FILE_INFO_FOLLOW_LINKS));
-	is_dir = FALSE;
-	if (result == GNOME_VFS_OK)
-		is_dir = (info->type == GNOME_VFS_FILE_TYPE_DIRECTORY);
+	uri = add_scheme_if_absent (path);
+	file = g_file_new_for_uri (uri);
 
-	gnome_vfs_file_info_unref (info);
+	result = gfile_path_is_dir (file);
+	
+	g_free (uri);
+	g_object_unref (file);
 
-	return is_dir;
+	return result;
 }
 
 
Index: src/catalog-web-exporter.c
===================================================================
--- src/catalog-web-exporter.c	(revision 2390)
+++ src/catalog-web-exporter.c	(working copy)
@@ -36,6 +36,7 @@
 
 #include "catalog-web-exporter.h"
 #include "comments.h"
+#include "gfile-utils.h"
 #include "file-utils.h"
 #include "gconf-utils.h"
 #include "jpegutils/jpeg-data.h"
@@ -1100,15 +1101,8 @@
 /* GFile to string */
 
 static char *
-file_get_uri (GFile *file)
-{
-	return g_file_get_uri (file);
-}
-
-
-static char *
-file_get_relative_uri (GFile *file, 
-		       GFile *relative_to)
+gfile_get_relative_uri (GFile *file, 
+		        GFile *relative_to)
 {
 	char  *escaped;
 	char  *relative_uri;
@@ -1114,8 +1108,8 @@
 	char  *relative_uri;
 	char  *result;
 	
-	escaped = file_get_uri (file);
-	relative_uri = file_get_uri (relative_to);
+	escaped = gfile_get_uri (file);
+	relative_uri = gfile_get_uri (relative_to);
 	
 	result = get_path_relative_to_uri (escaped, relative_uri);
 	
@@ -1127,26 +1121,12 @@
 
 
 static char *
-file_get_path (GFile *file)
+gfile_get_relative_path (GFile *file, 
+		         GFile *relative_to)
 {
 	char  *escaped, *unescaped;
-
-	escaped = g_file_get_path (file);
-	unescaped = g_uri_unescape_string (escaped, NULL);
 	
-	g_free (escaped);
-	
-	return unescaped;
-}
-
-
-static char *
-file_get_relative_path (GFile *file, 
-		        GFile *relative_to)
-{
-	char  *escaped, *unescaped;
-	
-	escaped = file_get_relative_uri (file, relative_to);
+	escaped = gfile_get_relative_uri (file, relative_to);
 	unescaped = g_uri_unescape_string (escaped, NULL);
 
 	g_free (escaped);
@@ -1155,6 +1135,7 @@
 }
 
 
+
 /* build a GFile (helpers) */
 
 GFile *
@@ -1538,7 +1519,7 @@
 			file = get_theme_file (ce, 
 					       ce->target_dir,
 					       src);
-			line = file_get_relative_uri (file, relative_to);
+			line = gfile_get_relative_uri (file, relative_to);
 			
 			write_markup_escape_line (line, fout);
 			
@@ -1576,7 +1557,7 @@
 				break;
 			}
 			
-			image_src = file_get_relative_uri (file, relative_to);
+			image_src = gfile_get_relative_uri (file, relative_to);
 			src_attr = _g_escape_text_for_html (image_src, -1);
 
 			class = gth_tag_get_str (ce, tag, "class");
@@ -1633,7 +1614,7 @@
 			file = get_html_image_file (ce, 
 						    idata, 
 						    ce->target_dir);
-			line = file_get_relative_uri (file, relative_to);
+			line = gfile_get_relative_uri (file, relative_to);
 			write_markup_escape_line (line, fout);
 
 			g_object_unref (file);
@@ -1686,10 +1667,10 @@
 			relative = (gth_tag_get_var (ce, tag, "with_relative_path") != 0);
 			
 			if (relative)
-				unescaped_path = file_get_relative_path (file, 
+				unescaped_path = gfile_get_relative_path (file, 
 									 relative_to);
 			else
-				unescaped_path = file_get_path (file);
+				unescaped_path = gfile_get_path (file);
 				
 			
 			if (relative || (gth_tag_get_var (ce, tag, "with_path") != 0)) {
@@ -1737,10 +1718,10 @@
 			relative = (gth_tag_get_var (ce, tag, "relative_path") != 0);
 
 			if (relative)
-				line = file_get_relative_path (dir, 
+				line = gfile_get_relative_path (dir, 
 							       relative_to);
 			else
-				line = file_get_path (dir);
+				line = gfile_get_path (dir);
 
 			if  (gth_tag_get_var (ce, tag, "utf8") != 0)
 				write_markup_escape_locale_line (line, fout);
@@ -1842,7 +1823,7 @@
 			file = get_html_index_file (ce, 
 						    idx, 
 						    ce->target_dir);
-			line = file_get_relative_uri (file, relative_to);
+			line = gfile_get_relative_uri (file, relative_to);
 			write_markup_escape_line (line, fout);
 
 			g_object_unref (file);
@@ -2227,7 +2208,7 @@
 			file = get_theme_file (ce, 
 					       ce->target_tmp_dir,
 					       info->name);
-			uri = file_get_uri (file);
+			uri = gfile_get_uri (file);
 			target_uri = gnome_vfs_uri_new (uri);
 			
 			source_uri_list = g_list_prepend (source_uri_list, source_uri);
@@ -2303,7 +2284,7 @@
 		file = get_thumbnail_file (ce, 
 					   idata, 
 					   ce->target_tmp_dir);
-		local_file = file_get_path (file);
+		local_file = gfile_get_path (file);
 		
 		debug (DEBUG_INFO, "save thumbnail: %s", local_file);
 
@@ -2374,7 +2355,7 @@
 	file = get_html_image_file (ce, 
 				    idata, 
 				    ce->target_tmp_dir);
-	local_file = file_get_path (file);
+	local_file = gfile_get_path (file);
 		
 	debug (DEBUG_INFO, "save html file: %s", local_file);
 
@@ -2456,7 +2437,7 @@
 				    ce->page, 
 				    ce->target_tmp_dir);
 
-	local_file = file_get_path (file);
+	local_file = gfile_get_path (file);
 
 	debug (DEBUG_INFO, "save html index: %s", local_file);
 
@@ -2584,7 +2565,7 @@
 			file = get_preview_file (ce, 
 						 idata, 
 						 ce->target_tmp_dir);
-			local_file = file_get_path (file);
+			local_file = gfile_get_path (file);
 
 			debug (DEBUG_INFO, "saving preview: %s", local_file);
 
@@ -2630,8 +2611,8 @@
 			file = get_image_file (ce, 
 					       idata, 
 					       ce->target_tmp_dir);
-			image_uri = file_get_uri (file);
-			local_file = file_get_path (file);
+			image_uri = gfile_get_uri (file);
+			local_file = gfile_get_path (file);
 			
 			debug (DEBUG_INFO, "saving image: %s", local_file);
 
@@ -2683,7 +2664,7 @@
 	file = get_image_file (ce, 
 			       idata, 
 			       ce->target_tmp_dir);
-	uri = file_get_uri (file);
+	uri = gfile_get_uri (file);
 	target_uri = gnome_vfs_uri_new (uri);
 		
 	result = gnome_vfs_xfer_uri (source_uri,
@@ -3051,23 +3032,9 @@
 }
 
 
-gboolean
-ensure_album_dir_exists_from_file (GFile *dir)
-{
-	char     *uri;
-	gboolean  ok;
-	
-	uri = file_get_uri (dir);
-	ok = ensure_dir_exists (uri, 0700);
-	
-	g_free (uri);
-
-	return ok;
-}
-
-
-gboolean
-ensure_album_dir_exists (GFile *target_dir, const char *subdir)
+static gboolean
+ensure_album_dir_exists (GFile *target_dir, 
+		         const char *subdir)
 {
 	gboolean  ok;
 	GFile    *dir;
@@ -3074,7 +3041,7 @@
 	
 	dir = file_resolve_relative_path (target_dir, subdir);
 	
-	ok = ensure_album_dir_exists_from_file (dir);
+	ok = gfile_ensure_dir_exists (dir, 0700, NULL);
 	
 	g_object_unref (dir);
 
@@ -3082,11 +3049,11 @@
 }
 
 
-void
+static void
 ensure_dir_structure (CatalogWebExporter *ce,
 		      GFile              *target_dir)
 {
-	ensure_album_dir_exists_from_file (target_dir);
+	gfile_ensure_dir_exists (target_dir, 0700, NULL);
 	
 	if (ce->use_subfolders) {
 		ensure_album_dir_exists (target_dir, ce->ad->previews);

