summaryrefslogtreecommitdiffabout
path: root/src/idx.c
Side-by-side diff
Diffstat (limited to 'src/idx.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/idx.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/idx.c b/src/idx.c
index 096e0ee..63b89bb 100644
--- a/src/idx.c
+++ b/src/idx.c
@@ -597,6 +597,16 @@ exp_filetime(char **ret, EVAL_ENV *env)
return WRDSE_UNDEF;
}
+static int
+exp_filetype(char **ret, EVAL_ENV *env)
+{
+ char const *s = " ";
+ if (env->ent)
+ s = S_ISDIR(env->ent->st.st_mode) ? "DIR" : "FILE";
+ *ret = xstrdup(s);
+ return WRDSE_OK;
+}
+
struct var_dcl {
char const *name;
int (*exp)(char **, EVAL_ENV *);
@@ -607,6 +617,7 @@ static struct var_dcl var_dcl[] = {
{ "FILENAME", exp_filename },
{ "FILESIZE", exp_filesize },
{ "FILETIME", exp_filetime },
+ { "FILETYPE", exp_filetype },
{ "MIMETYPE", exp_mimetype },
{ NULL }
};

Return to:

Send suggestions and report system problems to the System administrator.