grim/gplate

Parents 80a66152bfaa
Children 3ab8d04e9c94
added a type attribute to GPlateFileVariable which holds a string that represents the file type
--- a/gplate/variables/gplate-file-variable.c Sun Nov 15 01:57:35 2009 -0600
+++ b/gplate/variables/gplate-file-variable.c Sat Jun 19 20:28:56 2010 -0500
@@ -74,7 +74,7 @@
gplate_file_variable_real_refresh(GPlateFileVariable *file_variable) {
GPlateCollection *collection = NULL;
GPlateVariable *filename_var = NULL;
- const gchar *filename = NULL;
+ const gchar *filename = NULL, *type = NULL;
struct stat st;
collection = GPLATE_COLLECTION(file_variable);
@@ -108,6 +108,26 @@
gplate_collection_add_integer(collection, "atime", st.st_atime);
gplate_collection_add_integer(collection, "mtime", st.st_mtime);
gplate_collection_add_integer(collection, "ctime", st.st_ctime);
+
+ /* now add a type according to st_mode */
+ if(S_ISREG(st.st_mode))
+ type = "file";
+ else if(S_ISDIR(st.st_mode))
+ type = "directory";
+ else if(S_ISCHR(st.st_mode))
+ type = "character device";
+ else if(S_ISBLK(st.st_mode))
+ type = "block device";
+ else if(S_ISFIFO(st.st_mode))
+ type = "FIFO";
+ else if(S_ISLNK(st.st_mode))
+ type = "symbolic link";
+ else if(S_ISSOCK(st.st_mode))
+ type = "socket";
+ else
+ type = "unknown";
+
+ gplate_collection_add_string(collection, "type", type);
}
/******************************************************************************