2 * Copyright 2007 Johannes Lehtinen
3 * This file is free software; Johannes Lehtinen gives unlimited
4 * permission to copy, distribute and modify it.
13 #if defined(HAVE_LSTAT)
15 #elif defined(HAVE_STAT)
20 /* ------------------------------------------------------------------------
22 * ----------------------------------------------------------------------*/
25 * Classifies a file by using stat(2). This classifier does not need
26 * any classifier data so we use NULL as dummy data pointer. Therefore
27 * we do not need a plug-in instance either as there is no data to be
30 static int classify(void *dummy, const char *path) {
38 perror("stat failed");
40 // No point for other classifiers to classify this
44 // Check if this is a special file
45 if ((s.st_mode & S_IFMT) == S_IFDIR) {
48 } else if ((s.st_mode & S_IFMT) == S_IFCHR) {
49 type = "character device";
52 } else if ((s.st_mode & S_IFMT) == S_IFBLK) {
53 type = "block device";
56 } else if ((s.st_mode & S_IFMT) == S_IFLNK) {
57 type = "symbolic link";
61 // Did not recognize it, let other plug-ins try
65 // Print recognized file type
75 /* ------------------------------------------------------------------------
76 * Exported classifier information
77 * ----------------------------------------------------------------------*/
79 CP_EXPORT classifier_t cp_ex_cpfile_special_classifier = { NULL, classify };