config option for KDirWatch method

Andreas Pakulat apaku at gmx.de
Mon Aug 6 00:59:48 BST 2007


Hi,

in a KDirWatch related thread some time ago the issue was raised that
currently there's no way to change the method this class uses for
watching, because the order is hardcoded (fam, inotify, stat for linux).
As the available fam-methods are not yet fully stable and one of the
alternative's can't even be shut down (except by removing the
server-binary) I'd like to apply the attached patch after discussion.

What it does is simply reading a value from a new group in the
kdeglobals file (hope I have the KConfig code to get to that config file
right) and determines which method to prefer based on that.

If a QString is too costly for the key I can change that to an int or
something else, but I thought this way its easier for a possible kcm to
be implemented because you don't have to keep the int-values in sync
with kdirwatch.

This doesn't change API in any way, its BC and SC.

Andreas

PS: In case anybody noticed: I used inotify as default, which is just my
preference, changeable to fam before comitting of course ;)

-- 
You are number 6!  Who is number one?
-------------- next part --------------
Index: kdirwatch.cpp
===================================================================
--- kdirwatch.cpp	(Revision 695925)
+++ kdirwatch.cpp	(Arbeitskopie)
@@ -594,12 +594,24 @@
   if ( isNoisyFile( tpath ) )
     return;
 
+  KConfig config("kdeglobals");
+  KConfigGroup group("KDirWatch",&config);
+  QString method = group.readEntry("Watching Method", "inotify");
+  bool entryUsed;
 #if defined(HAVE_FAM)
-  if (useFAM(e)) return;
+  if (method == "fam")
+  {
+    entryUsed = useFAM(e)
+    if (entryUsed) return;
+  } 
 #endif
 
 #if defined(HAVE_SYS_INOTIFY_H)
-  if (useINotify(e)) return;
+  if (method == "inotify" || !entryUsed)
+  {
+    entryUsed = useINotify(e);
+    if (entryUsed) return;
+  }
 #endif
 
   useStat(e);


More information about the kde-core-devel mailing list