static int main (string[] args) {
// A reference to our file
var file = File.new_for_path ("data.txt");
+ var m = new Monitor();
return 0;
}
public void start()
{
for(int i = 0; i < this.monitors.size ; i++) {
- this.monitor(this.top[i], ( fm, f_orig, of_orig, event_type) => {} );
+ this.monitor(this.top[i], ( fm, f_orig, of_orig, event_type) => {
+ this.onEvent (fm, f_orig, of_orig, event_type ) ;
+ } );
}
}
/**
var f = File.new_for_path(path);
//var cancel = new Gio.Cancellable ();
- if (depth > 0) {
- var fm = f.monitor(FileMonitorFlags.SEND_MOVED,null); //Gio.FileMonitorFlags.SEND_MOVED
-
- fm.changed.connect( ( fm, f_orig, of_orig, event_type) => {
- if (fn) {
- fn (fm, f_orig, of_orig, event_type ) ;
- return;
- }
- this.onEvent (fm, f_orig, of_orig, event_type ) ;
- });
- this.monitors.add(fm);
+ if (depth > 0) {
+ try {
+
+ var fm = f.monitor(FileMonitorFlags.SEND_MOVED,null); //Gio.FileMonitorFlags.SEND_MOVED
+
+ fm.changed.connect( ( fm, f_orig, of_orig, event_type) => {
+ //if (fn) {
+ fn (fm, f_orig, of_orig, event_type ) ;
+ // return;
+ //}
+ //this.onEvent (fm, f_orig, of_orig, event_type ) ;
+ });
+ this.monitors.add(fm);
+
+ } catch (Error e) {
+ // FIXME -- show error? do nothing..
+ }
// print("ADD path " + depth + ' ' + path);
}
// iterate children?
// this.initRepo(path);
//}
-
-
- var file_enum = f.enumerate_children(
+ FileEnumerator file_enum;
+ try {
+ file_enum = f.enumerate_children(
FileAttribute.STANDARD_DISPLAY_NAME + "," + FileAttribute.STANDARD_TYPE,
0, // FileQueryInfoFlags.NONE,
null);
-
+ } catch (Error e) {
+ // FIXME - show error..
+ return;
+ }
FileInfo next_file;
- while ((next_file = file_enum.next_file(null)) != null) {
-
+ while (true) {
+ try {
+ next_file = file_enum.next_file(null);
+ } catch (Error e) {
+ break;
+ }
+ if (next_file == null) {
+ break;
+ }
//print("got a file " + next_file.sudo () + '?=' + Gio.FileType.DIRECTORY);
if (next_file.get_file_type() != FileType.DIRECTORY) {
this.monitor(sp, fn, depth + 1);
}
-
- file_enum.close(null);
+ try {
+ file_enum.close(null);
+ } catch(Error e) {
+ // ignore?
+ }
}