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 *
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;
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
#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 &&
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;