FAM (and xffm)

edscott wilson garcia edscott at imp.mx
Mon Feb 17 17:00:17 CET 2003


Just got back to town today. Actually function to look for changed and
deleted files is no problem in xffm. The trouble is that GtkTreeView
uses an elaborate cache scheme which takes up a lot of CPU. This makes
the tree flash annoyingly at times when the monitor is up. Replacing the
monitor function will not fix the problem. 

Edscott

El vie, 14-02-2003 a las 18:13, Jens Luedicke escribió:
> Hi ...
> 
> I thought about using FAM for xffm, and started to write some
> demo code to get into FAM.
> 
> Its fairly easy to monitor file changes.
> 
> The attached file monitors my homedir (/home/jens) and looks for
> changed, created and deleted files. 
> 
> It can be compiled with:
> 
> $ LDFLAGS=-lfam make fam
> 
> ./fam
> 
> If its ok, and wanted, I will dig myself into the xffm 
> code to look for possible uses. 
> 
> -- 
> Jens Luedicke <jens at irs-net.com>
> 
> "Never offend people with style when you can offend them with
> substance."
> --Sam Brown
> 
> 
> ----
> 

> #include <stdio.h>
> #include <stdlib.h>
> #include <fam.h>
> 
> int main(int argc, char *argv[]) {
> 	FAMConnection fc;
> 	FAMRequest fr;
> 	FAMEvent fe;
> 	
> 	if (FAMOpen(&fc) == -1) {
> 		printf("fam failed!\n");
> 		FAMClose(&fc);
> 	} else {
> 		printf("fam success!\n");
> 	}
> 
> 	if (FAMMonitorDirectory(&fc, "/home/jens", &fr, NULL) == -1) {
> 		printf("fam monitor failed!\n");
> 		FAMClose(&fc);
> 	} else {
> 		printf("fam monitor success!\n");
> 	}
> 
> 	while (1) {
> 
> 		if (FAMPending(&fc) == 1) {
> 			if (FAMNextEvent(&fc, &fe) == 1) {
> 				if (fe.code == FAMCreated) {
> 					printf("file created: %s\n", fe.filename);
> 				}
> 
> 				if (fe.code == FAMDeleted) {
> 					printf("file deleted: %s\n", fe.filename);
> 				}
> 
> 				if (fe.code == FAMChanged) {
> 					printf("file changed: %s\n", fe.filename);
> 				}
> 			} else {
> 				FAMClose(&fc);
> 				printf("FAMNextEvent failed!\n");
> 			}
> 		}
> 	}
> }





More information about the Xfce4-dev mailing list