summaryrefslogtreecommitdiff
path: root/mimetypes/eval.c
diff options
context:
space:
mode:
Diffstat (limited to 'mimetypes/eval.c')
-rw-r--r--mimetypes/eval.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/mimetypes/eval.c b/mimetypes/eval.c
index b2ad941..120d041 100644
--- a/mimetypes/eval.c
+++ b/mimetypes/eval.c
@@ -2,12 +2,13 @@
# include <config.h>
#endif
#include <fnmatch.h>
#include <inttypes.h>
#include <ctype.h>
#include <errno.h>
+#include <sys/stat.h>
#include "mtint.h"
static int eval_rule (struct node *root, struct filebuf const *file);
/* match("pattern")
Pattern match on filename
@@ -401,13 +402,19 @@ rule_cmp (struct rule const *arule, struct rule const *brule)
const char *
get_file_type (char const *filename)
{
struct rule *r;
struct rule *last = NULL;
struct filebuf fb;
+ struct stat st;
+ if (stat (filename, &st))
+ mimetypes_error ("can't stat %s: %s", filename, strerror (errno));
+ else if (S_ISDIR (st.st_mode))
+ return "directory";
+
fb.name = filename;
fb.fp = fopen (filename, "r");
if (fb.fp == NULL)
{
mimetypes_error ("can't open %s: %s", filename, strerror (errno));
return NULL;

Return to:

Send suggestions and report system problems to the System administrator.