Monitor.js
authorAlan Knowles <alan@wideboy.(none)>
Sat, 17 Apr 2010 02:07:32 +0000 (10:07 +0800)
committerAlan Knowles <alan@wideboy.(none)>
Sat, 17 Apr 2010 02:07:32 +0000 (10:07 +0800)
Monitor.js

index f7c40ea..54a77b5 100644 (file)
@@ -62,34 +62,38 @@ Monitor.prototype = {
         })
         this.monitors = [];
     },
-    
-    function monitor(
+    /**
+     * monitor a file or directory (privatish)
+     * 
+     * 
+     */
+    function monitor(path)
+    {
+        
        
-    ndirs++;
-    Seed.print("ADD path" + path);
-    var f = Gio.file_new_for_path(path);
-    //var cancel = new Gio.Cancellable ();
-    var fm = f.monitor(2,null); //Gio.FileMonitorFlags.SEND_MOVED
-    fm.signal.changed.connect(fn);
-    watches[path] = fm;
-    // iterate children?
-    
-    var file_enum = f.enumerate_children(
-        Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME + ','+ 
-        Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
-        Gio.FileQueryInfoFlags.NONE,
-        null);
+        var f = Gio.file_new_for_path(path);
+        //var cancel = new Gio.Cancellable ();
+        var fm = f.monitor(2,null); //Gio.FileMonitorFlags.SEND_MOVED
+        fm.signal.changed.connect(this.onChange, this);
+        this.monitors.push(fm);
+        // iterate children?
         
-    while ((next_file = file_enum.next_file(null)) != null) {
-     
-        if (next_file.get_file_type() != Gio.FileType.DIRECTORY) {
-            continue;
+        var file_enum = f.enumerate_children(
+            Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME + ','+ 
+            Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
+            Gio.FileQueryInfoFlags.NONE,
+            null);
+            
+        while ((next_file = file_enum.next_file(null)) != null) {
+         
+            if (next_file.get_file_type() != Gio.FileType.DIRECTORY) {
+                continue;
+            }
+            if (next_file.get_display_name()[0] == '.') {
+                continue;
+            }
+            this.monitor(path+'/'+next_file.get_display_name(), fn)
         }
-        if (next_file.get_display_name()[0] == '.') {
-            continue;
-        }
-        start_monitor(path+'/'+next_file.get_display_name(), fn)
-    }
     
     file_enum.close(null);