From 57cbeff08e786b0df6262816d050a7df664d0391 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 9 Mar 2004 00:34:17 +0000 Subject: [PATCH] Fixes #136080. 2004-03-08 Federico Mena Quintero Fixes #136080. * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to ENOENT. (filename_get_info): Likewise. --- ChangeLog | 8 +++++++ ChangeLog.pre-2-10 | 8 +++++++ ChangeLog.pre-2-4 | 8 +++++++ ChangeLog.pre-2-6 | 8 +++++++ ChangeLog.pre-2-8 | 8 +++++++ gtk/gtkfilesystemunix.c | 53 ++++++++++++++++++++++------------------- 6 files changed, 68 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9eaef33480..d8ad0f54cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-03-08 Federico Mena Quintero + + Fixes #136080. + + * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to + ENOENT. + (filename_get_info): Likewise. + 2004-03-08 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 9eaef33480..d8ad0f54cb 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-03-08 Federico Mena Quintero + + Fixes #136080. + + * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to + ENOENT. + (filename_get_info): Likewise. + 2004-03-08 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 9eaef33480..d8ad0f54cb 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,11 @@ +2004-03-08 Federico Mena Quintero + + Fixes #136080. + + * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to + ENOENT. + (filename_get_info): Likewise. + 2004-03-08 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 9eaef33480..d8ad0f54cb 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-03-08 Federico Mena Quintero + + Fixes #136080. + + * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to + ENOENT. + (filename_get_info): Likewise. + 2004-03-08 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 9eaef33480..d8ad0f54cb 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-03-08 Federico Mena Quintero + + Fixes #136080. + + * gtk/gtkfilesystemunix.c: Only lstat() if stat() failed due to + ENOENT. + (filename_get_info): Likewise. + 2004-03-08 Federico Mena Quintero * gtk/gtkfilechooserdefault.c diff --git a/gtk/gtkfilesystemunix.c b/gtk/gtkfilesystemunix.c index 5cffce9374..6e12713999 100644 --- a/gtk/gtkfilesystemunix.c +++ b/gtk/gtkfilesystemunix.c @@ -464,20 +464,22 @@ get_icon_type (const char *filename, /* If stat fails, try to fall back to lstat to catch broken links */ - if (stat (filename, &statbuf) != 0 && - lstat (filename, &statbuf) != 0) + if (stat (filename, &statbuf) != 0) { - 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); + if (errno != ENOENT || lstat (filename, &statbuf) != 0) + { + 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); - return ICON_NONE; + return ICON_NONE; + } } if (S_ISBLK (statbuf.st_mode)) @@ -1387,21 +1389,22 @@ filename_get_info (const gchar *filename, /* If stat fails, try to fall back to lstat to catch broken links */ - if (do_stat && - stat (filename, &statbuf) != 0 && - lstat (filename, &statbuf) != 0) + if (do_stat && stat (filename, &statbuf) != 0) { - 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); + if (errno != ENOENT || lstat (filename, &statbuf) != 0) + { + 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); - return NULL; + return NULL; + } } info = gtk_file_info_new ();