mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
File completion updates:
- ~/ isn't expanded to /home/xxx/ - . and .. don't show up in list anymore - .files won't be added to list unless you try to complete file name starting with . git-svn-id: http://svn.irssi.org/repos/irssi/trunk@367 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
d110c9cb3b
commit
e21e289b5d
@ -171,14 +171,18 @@ char *word_complete(WINDOW_REC *window, const char *line, int *pos)
|
|||||||
GList *list_add_file(GList *list, const char *name)
|
GList *list_add_file(GList *list, const char *name)
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
char *fname;
|
||||||
|
|
||||||
if (stat(name, &statbuf) != 0)
|
fname = convert_home(name);
|
||||||
return list;
|
if (stat(fname, &statbuf) == 0) {
|
||||||
|
list = g_list_append(list, !S_ISDIR(statbuf.st_mode) ? g_strdup(name) :
|
||||||
return g_list_append(list, !S_ISDIR(statbuf.st_mode) ? g_strdup(name) :
|
|
||||||
g_strconcat(name, G_DIR_SEPARATOR_S, NULL));
|
g_strconcat(name, G_DIR_SEPARATOR_S, NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free(fname);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
GList *filename_complete(const char *path)
|
GList *filename_complete(const char *path)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
@ -194,11 +198,24 @@ GList *filename_complete(const char *path)
|
|||||||
|
|
||||||
dir = g_dirname(realpath);
|
dir = g_dirname(realpath);
|
||||||
dirp = opendir(dir);
|
dirp = opendir(dir);
|
||||||
|
g_free(dir);
|
||||||
|
g_free(realpath);
|
||||||
|
|
||||||
basename = g_basename(realpath);
|
dir = g_dirname(path);
|
||||||
|
|
||||||
|
basename = g_basename(path);
|
||||||
len = strlen(basename);
|
len = strlen(basename);
|
||||||
|
|
||||||
while ((dp = readdir(dirp)) != NULL) {
|
while ((dp = readdir(dirp)) != NULL) {
|
||||||
|
if (dp->d_name[0] == '.') {
|
||||||
|
if (dp->d_name[1] == '\0' ||
|
||||||
|
(dp->d_name[1] == '.' && dp->d_name[2] == '\0'))
|
||||||
|
continue; /* skip . and .. */
|
||||||
|
|
||||||
|
if (basename[0] != '.')
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (len == 0 || strncmp(dp->d_name, basename, len) == 0) {
|
if (len == 0 || strncmp(dp->d_name, basename, len) == 0) {
|
||||||
name = g_strdup_printf("%s"G_DIR_SEPARATOR_S"%s", dir, dp->d_name);
|
name = g_strdup_printf("%s"G_DIR_SEPARATOR_S"%s", dir, dp->d_name);
|
||||||
list = list_add_file(list, name);
|
list = list_add_file(list, name);
|
||||||
@ -207,7 +224,6 @@ GList *filename_complete(const char *path)
|
|||||||
}
|
}
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
|
|
||||||
g_free(realpath);
|
|
||||||
g_free(dir);
|
g_free(dir);
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user