diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-09-27 14:02:28 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-09-27 14:02:28 +0200 |
commit | 962d1530ef87ff977262d1a7dc26b6427534abbd (patch) | |
tree | 432809062a3b11e583ca51e30e67d6d516620c11 | |
parent | e1d5f22845e1e33c847592e15667896fc24b7eab (diff) |
Ignore non-regular files in print-mime-data
-rw-r--r-- | src/print-mime-data.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/print-mime-data.c b/src/print-mime-data.c index b3baa14..9485534 100644 --- a/src/print-mime-data.c +++ b/src/print-mime-data.c @@ -110,6 +110,18 @@ test_by_file (const char *filename) printf ("\tfile: %s\n", mt); } +static int +is_regular (const char *filename) +{ + struct stat s; + + if (stat (filename, &s) == 0) + if (S_ISREG (s.st_mode)) + return 1; + + return 0; +} + static void process_file (const char *dir, const char *filename) { @@ -117,6 +129,9 @@ process_file (const char *dir, const char *filename) snprintf (path, 1024, "%s/%s", dir, filename); + if (!is_regular (path)) + return; + printf ("%s:\n", filename); test_by_name (filename); |