complete – file name completion
typedef struct Completion Completion;
uchar advance; /* whether forward progress has been made */
uchar complete; /* whether the completion now represents a file or directory */
char *string; /* the string to advance, suffixed " " or "/" for file or directory */
int nmatch; /* number of files that matched */
int nfile; /* number of files returned */
char **filename; /* their names */
Completion* complete(char *dir, char *s);
void freecompletion(Completion *c);
function implements file name completion.
Given a directory
and a string
it returns an analysis of the file names in that directory that begin with the string
will be set to the number of files that match the prefix and
will be filled in with their names.
If the file named is a directory, a slash character will be appended to it.
If no files match the string,
will be zero, but
will return the full set of files in the directory, with
set to their number.
reports whether the string
can be extended without changing the set of files that match. If true,
will be set to the extension; that is, the value of
may be appended to
by the caller to extend the embryonic file name unambiguously.
reports whether the extended file name uniquely identifies a file.
will be suffixed with a blank, or a slash and a blank,
depending on whether the resulting file name identifies a plain file or a directory.
function frees a
structure and its contents.
file name completion is triggered by a control-F character or an Insert character.
function returns a null pointer and sets
if the directory is unreadable or there is some other error.
The behavior of file name completion should be controlled by the plumber.