-
+ 44E3DF4102126EABBC8E4C0B424A650BD2AA11B1E1A84BD9169019A77DA0C3F4005D0A7708A8DBA5F005A642FAB96C0D9F02E788CCF6EEBF89246C8ADA039C73
vtools/lib/filetype.c
(0 . 0)(1 . 87)
865 /* Written by Paul Eggert. */
866
867 #include "filetype.h"
868
869 char const *
870 file_type(struct stat const *st) {
871 /* To keep diagnostics grammatical in English, the returned string
872 must start with a consonant. */
873
874 /* Do these three first, as they're the most common. */
875
876 if (S_ISREG (st->st_mode))
877 return st->st_size == 0 ? ("regular empty file") : ("regular file");
878
879 if (S_ISDIR (st->st_mode))
880 return ("directory");
881
882 if (S_ISLNK (st->st_mode))
883 return ("symbolic link");
884
885 #if 0
886 /* Do the |S_TYPEIS*| macros next, as they may be implemented in
887 terms of |S_ISNAM|, and we want the more-specialized
888 interpretation. */
889
890 if (S_TYPEISMQ (st))
891 return ("message queue");
892
893 if (S_TYPEISSEM (st))
894 return ("semaphore");
895
896 if (S_TYPEISSHM (st))
897 return ("shared memory object");
898
899 if (S_TYPEISTMO (st))
900 return ("typed memory object");
901
902 /* The remaining are in alphabetical order. */
903
904 if (S_ISBLK (st->st_mode))
905 return ("block special file");
906
907 if (S_ISCHR (st->st_mode))
908 return ("character special file");
909
910 if (S_ISCTG (st->st_mode))
911 return ("contiguous data");
912
913 if (S_ISFIFO (st->st_mode))
914 return ("fifo");
915
916 if (S_ISDOOR (st->st_mode))
917 return ("door");
918
919 if (S_ISMPB (st->st_mode))
920 return ("multiplexed block special file");
921
922 if (S_ISMPC (st->st_mode))
923 return ("multiplexed character special file");
924
925 if (S_ISMPX (st->st_mode))
926 return ("multiplexed file");
927
928 if (S_ISNAM (st->st_mode))
929 return ("named file");
930
931 if (S_ISNWK (st->st_mode))
932 return ("network special file");
933
934 if (S_ISOFD (st->st_mode))
935 return ("migrated file with data");
936
937 if (S_ISOFL (st->st_mode))
938 return ("migrated file without data");
939
940 if (S_ISPORT (st->st_mode))
941 return ("port");
942
943 if (S_ISSOCK (st->st_mode))
944 return ("socket");
945
946 if (S_ISWHT (st->st_mode))
947 return ("whiteout");
948 #endif
949
950 return ("weird file");
951 }