/// # valac --pkg gee-0.8 --pkg gio-2.0 --pkg posix Monitor.val
-using Gee; // for array list?
+//using Gee; // for array list?
static int main (string[] args) {
// A reference to our file
- var file = File.new_for_path ("data.txt");
- var m = new Monitor();
+ //var file = File.new_for_path ("data.txt");
+ //var m = new Monitor();
return 0;
}
{
- this.monitors = new ArrayList<FileMonitor> ();
- this.top = new ArrayList<string> ();
+ this.monitors = new Array<FileMonitor> ();
+ this.top = new Array<string> ();
this.paused = false;
}
- public ArrayList<FileMonitor> monitors;// Array of MonitorNamePathDirileMonitors
- public ArrayList<string> top; // list of top level directories..
+ public Array<FileMonitor> monitors;// Array of MonitorNamePathDirileMonitors
+ public Array<string> top; // list of top level directories..
public bool paused;
/**
* add a directory or file to monitor
*/
public void add (string add)
{
- this.top.add(add);
+ this.top.append_val(add);
}
/**
* start monitoring
*/
public void start()
{
- for(int i = 0; i < this.monitors.size ; i++) {
- this.monitor(this.top[i], ( fm, f_orig, of_orig, event_type) => {
+ for(int i = 0; i < this.monitors.length ; i++) {
+ this.monitor(this.top.index(i), ( fm, f_orig, of_orig, event_type) => {
this.onEvent (fm, f_orig, of_orig, event_type ) ;
} );
}
public void stop()
{
- for(int i = 0; i < this.monitors.size ; i++) {
- this.monitors[i].cancel();
+ for(int i = 0; i < this.monitors.length ; i++) {
+ this.monitors.index(i).cancel();
}
- this.monitors = new ArrayList<FileMonitor>(); // clean /destroy/ kill old?
+ this.monitors = new Array<FileMonitor>(); // clean /destroy/ kill old?
}
/**
* pause monitoring - without changing what's monitored
//}
//this.onEvent (fm, f_orig, of_orig, event_type ) ;
});
- this.monitors.add(fm);
+ this.monitors.append_val(fm);
} catch (Error e) {
- // do nothing..
+ // FIXME -- show error? do nothing..
}
// print("ADD path " + depth + ' ' + path);
}
// this.initRepo(path);
//}
-
-
- var file_enum = f.enumerate_children(
- FileAttribute.STANDARD_DISPLAY_NAME + "," + FileAttribute.STANDARD_TYPE,
- 0, // FileQueryInfoFlags.NONE,
- null);
-
+ 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?
+ }
}