summaryrefslogtreecommitdiff
path: root/gtk/gtkfilesystemunix.c
diff options
context:
space:
mode:
authorMorten Welinder <terra@gnome.org>2004-03-14 20:20:03 +0000
committerMorten Welinder <mortenw@src.gnome.org>2004-03-14 20:20:03 +0000
commit75b842b71f14897ae0b2c83930dd2c22fdd0a66c (patch)
tree482a4f7da93ae500e8ab07570e32a32a69491a2f /gtk/gtkfilesystemunix.c
parent79d73b1349fa815e7449b9b092509573685dd0bc (diff)
downloadgtk+-75b842b71f14897ae0b2c83930dd2c22fdd0a66c.tar.gz
Don't turn "/" into "". (gtk_file_system_unix_get_folder): Use the same
2004-03-14 Morten Welinder <terra@gnome.org> * gtk/gtkfilesystemunix.c (get_parent_dir): Don't turn "/" into "". (gtk_file_system_unix_get_folder): Use the same value for lookup as for insertion. Make sure we have a directory.
Diffstat (limited to 'gtk/gtkfilesystemunix.c')
-rw-r--r--gtk/gtkfilesystemunix.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c
index 5bf8c9accc..a479eb4b91 100644
--- a/gtk/gtkfilesystemunix.c
+++ b/gtk/gtkfilesystemunix.c
@@ -345,6 +345,7 @@ gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
GtkFileSystemUnix *system_unix;
GtkFileFolderUnix *folder_unix;
const char *filename;
+ char *filename_copy;
system_unix = GTK_FILE_SYSTEM_UNIX (file_system);
@@ -352,18 +353,35 @@ gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
- folder_unix = g_hash_table_lookup (system_unix->folder_hash, filename);
+ filename_copy = remove_trailing_slash (filename);
+ folder_unix = g_hash_table_lookup (system_unix->folder_hash, filename_copy);
if (folder_unix)
{
+ g_free (filename_copy);
folder_unix->types |= types;
return g_object_ref (folder_unix);
}
else
{
+ if (!g_file_test (filename, G_FILE_TEST_IS_DIR))
+ {
+ int save_errno = errno;
+ gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+ g_set_error (error,
+ GTK_FILE_SYSTEM_ERROR,
+ GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
+ _("error getting information for '%s': %s"),
+ filename_utf8 ? filename_utf8 : "???",
+ g_strerror (save_errno));
+ g_free (filename_utf8);
+ g_free (filename_copy);
+ return NULL;
+ }
+
folder_unix = g_object_new (GTK_TYPE_FILE_FOLDER_UNIX, NULL);
folder_unix->system_unix = system_unix;
- folder_unix->filename = remove_trailing_slash (filename);
+ folder_unix->filename = filename_copy;
folder_unix->types = types;
g_hash_table_insert (system_unix->folder_hash, folder_unix->filename, folder_unix);
@@ -615,7 +633,7 @@ get_parent_dir (const char *filename)
len = strlen (filename);
/* Ignore trailing slashes */
- if (filename[len - 1] == '/')
+ if (len > 1 && filename[len - 1] == '/')
{
char *tmp, *parent;