2005-12-01 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 1 Dec 2005 18:50:22 +0000 (18:50 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Thu, 1 Dec 2005 18:50:22 +0000 (18:50 -0000)
* FAMWatcher.cs:
* FileSystemWatcher.cs: use libgamin-1.so.0 instead of libfam.so.0 when
the runtime finds libgamin. On SUSE libgamin and libfam are not the same
libraries (on debian, they are just the same and there's no fam-server).

svn path=/trunk/mcs/; revision=53782

mcs/class/System/System.IO/ChangeLog
mcs/class/System/System.IO/FAMWatcher.cs
mcs/class/System/System.IO/FileSystemWatcher.cs

index 961c84255cbe8d148a2b534e69e1490047986edf..59d661f1d08a7fcf8652975671ec5af8e831bea5 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-01 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * FAMWatcher.cs: 
+       * FileSystemWatcher.cs: use libgamin-1.so.0 instead of libfam.so.0 when
+       the runtime finds libgamin. On SUSE libgamin and libfam are not the same
+       libraries (on debian, they are just the same and there's no fam-server).
+
 2005-06-25 Gonzalo Paniagua Javier <gonzalo@ximian.com>
 
        * FAMWatcher.cs: reverting my patch. Seems that something got
index c2998f3fcecb820f4a20842080ecbb6670b31a31..0eef6370dca4a5e24e09da1140e6189efa060c58 100644 (file)
@@ -77,13 +77,14 @@ namespace System.IO {
                static FAMConnection conn;
                static Thread thread;
                static bool stop;
+               static bool use_gamin;
                
                private FAMWatcher ()
                {
                }
                
                // Locked by caller
-               public static bool GetInstance (out IFileWatcher watcher)
+               public static bool GetInstance (out IFileWatcher watcher, bool gamin)
                {
                        if (failed == true) {
                                watcher = null;
@@ -95,6 +96,7 @@ namespace System.IO {
                                return true;
                        }
 
+                       use_gamin = gamin;
                        watches = Hashtable.Synchronized (new Hashtable ());
                        requests = Hashtable.Synchronized (new Hashtable ());
                        if (FAMOpen (out conn) == -1) {
@@ -335,25 +337,79 @@ namespace System.IO {
                        FAMClose (ref conn);
                }
 
-               [DllImport ("libfam.so.0")]
-               extern static int FAMOpen (out FAMConnection fc);
+               static int FAMOpen (out FAMConnection fc)
+               {
+                       if (use_gamin)
+                               return gamin_Open (out fc);
+                       return fam_Open (out fc);
+               }
+
+               static int FAMClose (ref FAMConnection fc)
+               {
+                       if (use_gamin)
+                               return gamin_Close (ref fc);
+                       return fam_Close (ref fc);
+               }
+
+               static int FAMMonitorDirectory (ref FAMConnection fc, string filename, out FAMRequest fr, IntPtr user_data)
+               {
+                       if (use_gamin)
+                               return gamin_MonitorDirectory (ref fc, filename, out fr, user_data);
+                       return fam_MonitorDirectory (ref fc, filename, out fr, user_data);
+               }
+
+               static int FAMCancelMonitor (ref FAMConnection fc, ref FAMRequest fr)
+               {
+                       if (use_gamin)
+                               return gamin_CancelMonitor (ref fc, ref fr);
+                       return fam_CancelMonitor (ref fc, ref fr);
+               }
+
+               static int FAMPending (ref FAMConnection fc)
+               {
+                       if (use_gamin)
+                               return gamin_Pending (ref fc);
+                       return fam_Pending (ref fc);
+               }
+
+
+               
+               [DllImport ("libfam.so.0", EntryPoint="FAMOpen")]
+               extern static int fam_Open (out FAMConnection fc);
+
+               [DllImport ("libfam.so.0", EntryPoint="FAMClose")]
+               extern static int fam_Close (ref FAMConnection fc);
 
-               [DllImport ("libfam.so.0")]
-               extern static int FAMClose (ref FAMConnection fc);
+               [DllImport ("libfam.so.0", EntryPoint="FAMMonitorDirectory")]
+               extern static int fam_MonitorDirectory (ref FAMConnection fc, string filename,
+                                                       out FAMRequest fr, IntPtr user_data);
+
+               [DllImport ("libfam.so.0", EntryPoint="FAMCancelMonitor")]
+               extern static int fam_CancelMonitor (ref FAMConnection fc, ref FAMRequest fr);
+
+               [DllImport ("libfam.so.0", EntryPoint="FAMPending")]
+               extern static int fam_Pending (ref FAMConnection fc);
 
-               [DllImport ("libfam.so.0")]
-               extern static int FAMMonitorDirectory (ref FAMConnection fc, string filename,
+               [DllImport ("libgamin-1.so.0", EntryPoint="FAMOpen")]
+               extern static int gamin_Open (out FAMConnection fc);
+
+               [DllImport ("libgamin-1.so.0", EntryPoint="FAMClose")]
+               extern static int gamin_Close (ref FAMConnection fc);
+
+               [DllImport ("libgamin-1.so.0", EntryPoint="FAMMonitorDirectory")]
+               extern static int gamin_MonitorDirectory (ref FAMConnection fc, string filename,
                                                        out FAMRequest fr, IntPtr user_data);
 
-               [DllImport ("libfam.so.0")]
-               extern static int FAMCancelMonitor (ref FAMConnection fc, ref FAMRequest fr);
+               [DllImport ("libgamin-1.so.0", EntryPoint="FAMCancelMonitor")]
+               extern static int gamin_CancelMonitor (ref FAMConnection fc, ref FAMRequest fr);
+
+               [DllImport ("libgamin-1.so.0", EntryPoint="FAMPending")]
+               extern static int gamin_Pending (ref FAMConnection fc);
 
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                extern static int InternalFAMNextEvent (ref FAMConnection fc, out string filename,
                                                        out int code, out int reqnum);
 
-               [DllImport ("libfam.so.0")]
-               extern static int FAMPending (ref FAMConnection fc);
        }
 }
 
index d3d421ccc21e40ba9d2e166e9914c0156a2fcc27..c23400daefe061bcf8b7498655e2ad50083e63b4 100644 (file)
@@ -115,13 +115,21 @@ namespace System.IO {
                                        mode = InternalSupportsFSW ();
 
                                bool ok = false;
-                               if (mode == 3)
-                                       ok = KeventWatcher.GetInstance (out watcher);
-                               else if (mode == 2)
-                                       ok = FAMWatcher.GetInstance (out watcher);
-                               else if (mode == 1)
+                               switch (mode) {
+                               case 1: // windows
                                        ok = DefaultWatcher.GetInstance (out watcher);
                                        //ok = WindowsWatcher.GetInstance (out watcher);
+                                       break;
+                               case 2: // libfam
+                                       ok = FAMWatcher.GetInstance (out watcher, false);
+                                       break;
+                               case 3: // kevent
+                                       ok = KeventWatcher.GetInstance (out watcher);
+                                       break;
+                               case 4: // libgamin
+                                       ok = FAMWatcher.GetInstance (out watcher, true);
+                                       break;
+                               }
 
                                if (mode == 0 || !ok)
                                        DefaultWatcher.GetInstance (out watcher);