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,
@@ -249,7 +249,7 @@
 GnomeVFSResult      _gnome_vfs_write_line         (GnomeVFSHandle   *handle,
 						   const char       *format,
 						   ...);
-GnomeVFSFileSize    get_destination_free_space    (const char       *path);
+guint64             get_destination_free_space    (const char       *path);
 const char *        get_mime_type                 (const char       *path);
 const char*         get_file_mime_type            (const char       *path,
 						   gboolean          fast_file_type);
Index: libgthumb/gfile-utils.c
===================================================================
--- libgthumb/gfile-utils.c	(revision 2390)
+++ libgthumb/gfile-utils.c	(working copy)
@@ -21,3 +21,313 @@
  */
 
 
+#include <stdlib.h>
+#include <glib.h>
+
+#include "gfile-utils.h"
+
+
+/*
+ * NOTE: All these functions accept/return _only_ uri-style GFiles.
+ */
+
+
+
+/* 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;
+}
+
+
+gboolean
+gfile_is_local (GFile *file)
+{
+	return g_file_has_uri_scheme (file, "file");
+}
+
+
+guint64
+gfile_get_destination_free_space (GFile *file)
+{
+	guint64    freespace = 0;
+	GFileInfo *info;
+	GError    *err = NULL;
+
+	info = g_file_query_filesystem_info (file, 
+			                     G_FILE_ATTRIBUTE_FILESYSTEM_FREE, 
+			                     NULL, 
+			                     &err);
+	if (info != NULL) {
+		freespace = g_file_info_get_attribute_uint64 (info, 
+				                              G_FILE_ATTRIBUTE_FILESYSTEM_FREE);
+		g_object_unref (info);
+	}
+	else {
+		gfile_warning ("Could not get filesystem free space on volume containing the file", 
+			       file, 
+			       err);
+		g_error_free (err);
+	}
+
+	return freespace;
+}
+
+
+GFile *
+gfile_get_home_dir (void)
+{
+	GFile *dir;
+	char  *path;
+	
+	path = g_strconcat ("file://", g_get_home_dir (), NULL);
+	dir = g_file_new_for_uri (path);
+	
+	g_free (path);
+	
+	return dir;
+}
+
+
+GFile *
+gfile_get_tmp_dir (void)
+{
+	GFile *dir;
+	char  *path;
+	
+	path = g_strconcat ("file://", g_get_tmp_dir (), NULL);
+	dir = g_file_new_for_uri (path);
+	
+	g_free (path);
+	
+	return dir;
+}
+
+
+#define MAX_TEMP_FOLDER_TO_TRY  2
+
+static GFile *
+ith_temp_folder_to_try (int n)
+{
+	GFile *dir = NULL;
+	
+	if (n == 1)
+		dir = gfile_get_home_dir ();
+	else if (n == 2)
+		dir = gfile_get_tmp_dir ();
+	
+	return dir;
+}
+
+
+GFile *
+gfile_make_temp_in_dir (GFile *in_dir)
+{
+	char  *path0;
+	char  *path1;
+	char  *path2;
+	char  *template;
+	GFile *dir;
+	
+	path0 = g_file_get_path (in_dir);
+	template = g_strconcat (path0, "/.gt-XXXXXX", NULL);
+	g_free (path0);
+
+	path1 = mkdtemp (template);
+	
+	if (path1 == NULL)
+		return NULL;
+	
+	path2 = g_strconcat ("file://", path1, NULL);
+	dir = g_file_new_for_uri (path2);
+	
+	g_free (path1);
+	g_free (path2);
+	
+	return dir;
+}
+
+
+GFile *
+gfile_get_temp_dir_name (void)
+{
+	int      i;
+	guint64  max_size = 0;
+	GFile   *best_folder = NULL;
+	GFile   *tmp_dir;
+
+	/* find the folder with more free space. */
+
+	for (i = 1; i <= MAX_TEMP_FOLDER_TO_TRY; i++) {
+		GFile    *folder;
+		guint64   size;
+
+		folder = ith_temp_folder_to_try (i);
+		size = gfile_get_destination_free_space (folder);
+		if (max_size < size) {
+			max_size = size;
+			UNREF (best_folder)
+			best_folder = folder;
+		}
+		else
+			g_object_unref (folder);
+	}
+
+	if (best_folder == NULL)
+		return NULL;
+	
+	if (! gfile_is_local (best_folder)) {
+		g_object_unref (best_folder);
+		return NULL;
+	}
+
+	tmp_dir = gfile_make_temp_in_dir (best_folder);
+	
+	g_object_unref (best_folder);
+
+	return tmp_dir;
+}
Index: libgthumb/gfile-utils.h
===================================================================
--- libgthumb/gfile-utils.h	(revision 2390)
+++ libgthumb/gfile-utils.h	(working copy)
@@ -23,5 +23,42 @@
 #ifndef GFILE_UTILS_H
 #define GFILE_UTILS_H
 
-					       
+#include <gio/gio.h>
+
+
+#define UNREF(obj) {				\
+	if (obj != NULL) {			\
+		g_object_unref (obj);		\
+		obj = NULL;			\
+	}					\
+}
+
+/*
+ * NOTE: All these functions accept/return _only_ uri-style GFiles.
+ */
+
+/* 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);
+guint64       gfile_get_destination_free_space (GFile      *file);
+GFile *       gfile_get_temp_dir_name          (void);
+
 #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);
-
-	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);
+	
+	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);
 
-	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);
-
-	gnome_vfs_file_info_unref (info);
+	
+	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);
 
-	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;
 }
 
 
@@ -2458,24 +2426,7 @@
 
 /* temp */
 
-
-static const char *try_folder[] = { "~", "tmp", NULL };
-
-
-static const char *
-get_folder_from_try_folder_list (int n)
-{
-        const char *folder;
-
-        folder = try_folder[n];
-        if (strcmp (folder, "~") == 0)
-                folder = g_get_home_dir ();
-        else if (strcmp (folder, "tmp") == 0)
-                folder = g_get_tmp_dir ();
-
-        return folder;
-}
-
+/* Note: callers of get_temp_dir_name seem to expect a path */
 
 char *
 get_temp_dir_name (void)
@@ -2480,46 +2431,19 @@
 char *
 get_temp_dir_name (void)
 {
-        GnomeVFSFileSize  max_size = 0;
-        char             *best_folder = NULL;
-        int               i;
-        char             *template;
-        char             *result = NULL;
-
-        /* find the folder with the bigger free space. */
-
-        for (i = 0; try_folder[i] != NULL; i++) {
-                const char       *folder;
-                char             *uri;
-                GnomeVFSFileSize  size;
-
-                folder = get_folder_from_try_folder_list (i);
-                uri = get_uri_from_local_path (folder);
-
-                size = get_destination_free_space (uri);
-                if (size > max_size) {
-                        max_size = size;
-                        g_free (best_folder);
-                        best_folder = get_local_path_from_uri (uri);
-                }
-                else
-                        g_free (uri);
-        }
-
-	if (best_folder == NULL)
+	GFile *dir;
+	char  *path;
+	
+	dir = gfile_get_temp_dir_name ();
+	
+	if (dir == NULL)
 		return NULL;
-
-        template = g_strconcat (best_folder, "/.gth-XXXXXX", NULL);
-        g_free (best_folder);
-        
-        result = mkdtemp (template);
-
-        if ((result == NULL) || (*result == '\0')) {
-                g_free (template);
-                result = NULL;
-        }
-
-        return result;
+	
+	path = g_file_get_path (dir);
+	
+	g_object_unref (dir);
+	
+	return path;
 }
 
 
@@ -2766,21 +2690,25 @@
 }
 
 
-GnomeVFSFileSize
-get_destination_free_space (const char *uri)
+guint64
+get_destination_free_space (const char *path)
 {
-        GnomeVFSURI      *vfs_uri;
-        GnomeVFSResult    result;
-        GnomeVFSFileSize  free_space;
+	GFile    *file;
+	gboolean  result;
+	char     *uri;
+	
+	if (path == NULL)
+		return FALSE;
+	
+	uri = add_scheme_if_absent (path);
+	file = g_file_new_for_uri (uri);
 
-        vfs_uri = gnome_vfs_uri_new (uri);
-        result = gnome_vfs_get_volume_free_space (vfs_uri, &free_space);
-        gnome_vfs_uri_unref (vfs_uri);
+	result = gfile_get_destination_free_space (file);
+	
+	g_free (uri);
+	g_object_unref (file);
 
-        if (result != GNOME_VFS_OK)
-                return (GnomeVFSFileSize) 0;
-        else
-                return free_space;
+	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"
@@ -88,13 +89,6 @@
 #define SAVING_TIMEOUT 5
 
 
-#define UNREF(obj) {				\
-	if (obj != NULL) {			\
-		g_object_unref (obj);		\
-		obj = NULL;			\
-	}					\
-}
-
 /* Default subdirectories.
  * - Used as fallback when gconf values are empty or not accessible
  * - Please keep in sync with values in gthumb.schemas.in 
@@ -1100,15 +1094,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 +1101,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 +1114,12 @@
 
 
 static char *
-file_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;
-}
-
-
-static char *
-file_get_relative_path (GFile *file, 
-		        GFile *relative_to)
+gfile_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 +1128,7 @@
 }
 
 
+
 /* build a GFile (helpers) */
 
 GFile *
@@ -1538,7 +1512,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 +1550,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 +1607,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 +1660,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 +1711,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 +1816,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 +2201,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 +2277,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 +2348,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 +2430,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 +2558,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 +2604,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 +2657,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 +3025,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 +3034,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 +3042,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);
@@ -3104,8 +3064,6 @@
 void
 catalog_web_exporter_export (CatalogWebExporter *ce)
 {
-	char	*tmp_dir;
-	
 	g_return_if_fail (IS_CATALOG_WEB_EXPORTER (ce));
 
 	if ((ce->exporting) || (ce->file_list == NULL))
@@ -3124,9 +3082,10 @@
 
 	/* get tmp dir */
 
-	tmp_dir = get_temp_dir_name ();
+	UNREF (ce->target_tmp_dir)
+	ce->target_tmp_dir = gfile_get_temp_dir_name ();
 	
-	if (tmp_dir == NULL) {
+	if (ce->target_tmp_dir == NULL) {
 		_gtk_error_dialog_run (GTK_WINDOW (ce->window), _("Could not create a temporary folder"));
 		g_signal_emit (G_OBJECT (ce), catalog_web_exporter_signals[WEB_EXPORTER_DONE], 0);
 		return;
@@ -3131,12 +3090,13 @@
 		g_signal_emit (G_OBJECT (ce), catalog_web_exporter_signals[WEB_EXPORTER_DONE], 0);
 		return;
 	}
-	
-	debug (DEBUG_INFO, "temp dir: %s", tmp_dir);
-
-	UNREF (ce->target_tmp_dir)
-	ce->target_tmp_dir = g_file_new_for_path (tmp_dir);
-	g_free (tmp_dir);
+	else {
+		char	*tmp_dir;
+		
+		tmp_dir = gfile_get_path (ce->target_tmp_dir);
+		debug (DEBUG_INFO, "temp dir: %s", tmp_dir);
+		g_free (tmp_dir);
+	}
 
 	/* compute n_images, n_pages */
 	

