Changeset 1418:9d792ba0ff49

Show
Ignore:
Timestamp:
1999-12-29 10:35:00 (9 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Fix the use of link_is_dir() in the file browser. This should fix
the bug reported by John Yates <yates@…> on Dec 07 1999.
(Details noted by Byrial Jensen <byrial@…> on Dec 09 1999.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • browser.c

    r1414 r1418  
    123123} 
    124124 
    125 static int link_is_dir (const char *path) 
     125static int link_is_dir (const char *folder, const char *path) 
    126126{ 
    127127  struct stat st; 
    128  
    129   if (stat (path, &st) == 0) 
     128  char fullpath[_POSIX_PATH_MAX]; 
     129   
     130  snprintf (fullpath, sizeof (fullpath), "%s/%s", folder, path); 
     131   
     132  if (stat (fullpath, &st) == 0) 
    130133    return (S_ISDIR (st.st_mode)); 
    131134  else 
    132     return (-1); 
     135    return 0; 
    133136} 
    134137 
     
    493496{ 
    494497  struct folder_file *ff = &(((struct folder_file *)menu->data)[n]); 
    495   if (S_ISDIR (ff->mode) || (S_ISLNK (ff->mode) && link_is_dir (ff->name))) 
     498  if (S_ISDIR (ff->mode) || (S_ISLNK (ff->mode) && link_is_dir (LastDir, ff->name))) 
    496499  { 
    497500    mutt_error _("Can't attach a directory!"); 
     
    619622        if (S_ISDIR (state.entry[menu->current].mode) || 
    620623            (S_ISLNK (state.entry[menu->current].mode) && 
    621             link_is_dir (state.entry[menu->current].name))  
     624            link_is_dir (LastDir, state.entry[menu->current].name))  
    622625#ifdef USE_IMAP 
    623626            || state.entry[menu->current].notfolder 
     
    844847        if (!state.imap_browse) 
    845848#endif 
    846         {/* add '/' at the end of the directory name */ 
    847         int len=mutt_strlen(LastDir); 
    848         if (sizeof (buf) > len) 
    849           buf[len]='/'; 
     849        { 
     850          /* add '/' at the end of the directory name */ 
     851          int len=mutt_strlen(LastDir); 
     852          if (sizeof (buf) > len) 
     853            buf[len]='/'; 
    850854        } 
    851855 
     
    10581062        if (S_ISDIR (state.entry[menu->current].mode) || 
    10591063            (S_ISLNK (state.entry[menu->current].mode) && 
    1060             link_is_dir (state.entry[menu->current].name))) 
     1064            link_is_dir (LastDir, state.entry[menu->current].name))) 
    10611065        { 
    10621066          mutt_error _("Can't view a directory");