From d9441cc6f31804b0cddc58eba897e0bbd56ede06 Mon Sep 17 00:00:00 2001 From: "J. Ali Harlow" Date: Wed, 24 Mar 2004 16:50:56 +0000 Subject: [PATCH] Test that path is actually a directory and throw error if not. Fixed bug 2004-03-24 J. Ali Harlow * gtk/gtkfilesystemwin32.c (gtk_file_system_win32_get_folder): Test that path is actually a directory and throw error if not. Fixed bug #137950 --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ ChangeLog.pre-2-4 | 6 ++++++ ChangeLog.pre-2-6 | 6 ++++++ ChangeLog.pre-2-8 | 6 ++++++ gtk/gtkfilesystemwin32.c | 28 ++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9ec56fe234..875718d84b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-03-24 J. Ali Harlow + + * gtk/gtkfilesystemwin32.c + (gtk_file_system_win32_get_folder): Test that path is actually + a directory and throw error if not. Fixed bug #137950 + 2004-03-22 J. Ali Harlow * gtk/gtkfilesystemwin32.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9ec56fe234..875718d84b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2004-03-24 J. Ali Harlow + + * gtk/gtkfilesystemwin32.c + (gtk_file_system_win32_get_folder): Test that path is actually + a directory and throw error if not. Fixed bug #137950 + 2004-03-22 J. Ali Harlow * gtk/gtkfilesystemwin32.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9ec56fe234..875718d84b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +2004-03-24 J. Ali Harlow + + * gtk/gtkfilesystemwin32.c + (gtk_file_system_win32_get_folder): Test that path is actually + a directory and throw error if not. Fixed bug #137950 + 2004-03-22 J. Ali Harlow * gtk/gtkfilesystemwin32.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9ec56fe234..875718d84b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +2004-03-24 J. Ali Harlow + + * gtk/gtkfilesystemwin32.c + (gtk_file_system_win32_get_folder): Test that path is actually + a directory and throw error if not. Fixed bug #137950 + 2004-03-22 J. Ali Harlow * gtk/gtkfilesystemwin32.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9ec56fe234..875718d84b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +2004-03-24 J. Ali Harlow + + * gtk/gtkfilesystemwin32.c + (gtk_file_system_win32_get_folder): Test that path is actually + a directory and throw error if not. Fixed bug #137950 + 2004-03-22 J. Ali Harlow * gtk/gtkfilesystemwin32.c diff --git a/gtk/gtkfilesystemwin32.c b/gtk/gtkfilesystemwin32.c index c629071a87..6064a86809 100644 --- a/gtk/gtkfilesystemwin32.c +++ b/gtk/gtkfilesystemwin32.c @@ -345,6 +345,34 @@ gtk_file_system_win32_get_folder (GtkFileSystem *file_system, filename = filename_from_path (path); g_return_val_if_fail (filename != NULL, NULL); + 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); + + /* If g_file_test() returned FALSE but not due to an error, it means + * that the filename is not a directory. + */ + if (save_errno == 0) + /* ENOTDIR */ + g_set_error (error, + GTK_FILE_SYSTEM_ERROR, + GTK_FILE_SYSTEM_ERROR_NOT_FOLDER, + _("%s: %s"), + filename_utf8 ? filename_utf8 : "???", + g_strerror (ENOTDIR)); + else + 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); + return NULL; + } + folder_win32 = g_object_new (GTK_TYPE_FILE_FOLDER_WIN32, NULL); folder_win32->filename = filename; folder_win32->types = types;