From 0bc084770c02c3b838f3260ad57db1ca4b52630c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 25 Jun 2000 21:59:30 +0000 Subject: [PATCH] File name completion crashed if you tried to complete file in directory that didn't exist or you didn't have read permission. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@375 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/core/completion.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/fe-common/core/completion.c b/src/fe-common/core/completion.c index dd06876d..e545451b 100644 --- a/src/fe-common/core/completion.c +++ b/src/fe-common/core/completion.c @@ -193,19 +193,21 @@ GList *filename_complete(const char *path) list = NULL; - realpath = strncmp(path, "~/", 2) != 0 ? g_strdup(path) : - g_strconcat(g_get_home_dir(), path+1, NULL); - + /* get directory part of the path - expand ~/ */ + realpath = convert_home(path); dir = g_dirname(realpath); - dirp = opendir(dir); - g_free(dir); g_free(realpath); - dir = g_dirname(path); + /* open directory for reading */ + dirp = opendir(dir); + g_free(dir); + if (dirp == NULL) return NULL; + dir = g_dirname(path); basename = g_basename(path); len = strlen(basename); + /* add all files in directory to completion list */ while ((dp = readdir(dirp)) != NULL) { if (dp->d_name[0] == '.') { if (dp->d_name[1] == '\0' ||