]> granicus.if.org Git - mutt/commitdiff
Fix the use of link_is_dir() in the file browser. This should fix
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 29 Dec 1999 18:35:00 +0000 (18:35 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 29 Dec 1999 18:35:00 +0000 (18:35 +0000)
the bug reported by John Yates <yates@flatiron.com> on Dec 07 1999.
(Details noted by Byrial Jensen <byrial@image.dk> on Dec 09 1999.)

browser.c

index 0f4f04ce18e6f904c63c1a5bb8a9b2068187052f..b889be565d34832387e633d30014526513cb0820 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -122,14 +122,17 @@ static void browser_sort (struct browser_state *state)
   qsort (state->entry, state->entrylen, sizeof (struct folder_file), f);
 }
 
-static int link_is_dir (const char *path)
+static int link_is_dir (const char *folder, const char *path)
 {
   struct stat st;
-
-  if (stat (path, &st) == 0)
+  char fullpath[_POSIX_PATH_MAX];
+  
+  snprintf (fullpath, sizeof (fullpath), "%s/%s", folder, path);
+  
+  if (stat (fullpath, &st) == 0)
     return (S_ISDIR (st.st_mode));
   else
-    return (-1);
+    return 0;
 }
 
 static const char *
@@ -492,7 +495,7 @@ static void init_menu (struct browser_state *state, MUTTMENU *menu, char *title,
 int file_tag (MUTTMENU *menu, int n)
 {
   struct folder_file *ff = &(((struct folder_file *)menu->data)[n]);
-  if (S_ISDIR (ff->mode) || (S_ISLNK (ff->mode) && link_is_dir (ff->name)))
+  if (S_ISDIR (ff->mode) || (S_ISLNK (ff->mode) && link_is_dir (LastDir, ff->name)))
   {
     mutt_error _("Can't attach a directory!");
     return 0;
@@ -618,7 +621,7 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
 
         if (S_ISDIR (state.entry[menu->current].mode) ||
            (S_ISLNK (state.entry[menu->current].mode) &&
-           link_is_dir (state.entry[menu->current].name)) 
+           link_is_dir (LastDir, state.entry[menu->current].name)) 
 #ifdef USE_IMAP
            || state.entry[menu->current].notfolder
 #endif
@@ -843,10 +846,11 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
 #ifdef USE_IMAP
        if (!state.imap_browse)
 #endif
-       {/* add '/' at the end of the directory name */
-       int len=mutt_strlen(LastDir);
-       if (sizeof (buf) > len)
-         buf[len]='/';
+       {
+         /* add '/' at the end of the directory name */
+         int len=mutt_strlen(LastDir);
+         if (sizeof (buf) > len)
+           buf[len]='/';
        }
 
        if (mutt_get_field (_("Chdir to: "), buf, sizeof (buf), M_FILE) == 0 &&
@@ -1057,7 +1061,7 @@ void _mutt_select_file (char *f, size_t flen, int buffy,
 
         if (S_ISDIR (state.entry[menu->current].mode) ||
            (S_ISLNK (state.entry[menu->current].mode) &&
-           link_is_dir (state.entry[menu->current].name)))
+           link_is_dir (LastDir, state.entry[menu->current].name)))
        {
          mutt_error _("Can't view a directory");
          break;