1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22: #include <config.h>
23:
24: #include "file-type.h"
25:
26: #include <gettext.h>
27: #define _(text) gettext (text)
28:
29: char const *
30: file_type (struct stat const *st)
31: {
32:
33:
34:
35:
36:
37:
38: if (S_ISREG (st->st_mode))
39: return st->st_size == 0 ? _("regular empty file") : _("regular file");
40:
41: if (S_ISDIR (st->st_mode))
42: return _("directory");
43:
44: if (S_ISBLK (st->st_mode))
45: return _("block special file");
46:
47: if (S_ISCHR (st->st_mode))
48: return _("character special file");
49:
50: if (S_ISFIFO (st->st_mode))
51: return _("fifo");
52:
53: if (S_ISLNK (st->st_mode))
54: return _("symbolic link");
55:
56: if (S_ISSOCK (st->st_mode))
57: return _("socket");
58:
59: if (S_TYPEISMQ (st))
60: return _("message queue");
61:
62: if (S_TYPEISSEM (st))
63: return _("semaphore");
64:
65: if (S_TYPEISSHM (st))
66: return _("shared memory object");
67:
68: if (S_TYPEISTMO (st))
69: return _("typed memory object");
70:
71: return _("weird file");
72: }