summaryrefslogtreecommitdiff
path: root/src/fe-common
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-25 21:59:30 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-25 21:59:30 +0000
commit0bc084770c02c3b838f3260ad57db1ca4b52630c (patch)
tree2d2a11516065ea59cd799ab98940ffca9530f0a0 /src/fe-common
parentcb1666cb21cb3cdf2480eb427440537d39f72963 (diff)
downloadirssi-0bc084770c02c3b838f3260ad57db1ca4b52630c.zip
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
Diffstat (limited to 'src/fe-common')
-rw-r--r--src/fe-common/core/completion.c12
1 files changed, 7 insertions, 5 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);
+ g_free(realpath);
+
+ /* open directory for reading */
dirp = opendir(dir);
g_free(dir);
- g_free(realpath);
+ 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' ||