[PATCH]: Re: [Nautilus-list] Re: must not ship Nautilus 1.0.4 until we fix FAM support



Yoann Vandoorselaere <yoann mandrakesoft com> writes:

> Darin Adler <darin bentspoon com> writes:
> 
> > On Saturday, June 16, 2001, at 12:04  AM, Yoann Vandoorselaere wrote:
> > 
> > >>> Now if FAM is going to be a requirement for Nautilus,
> > >>> it will directly link FAM. So that wouldn't be an issue anymore.
> > >>>
> > >>> One of theses should probably be done for 1.0.4.
> > >
> > > Decide whether FAM is optional or not. Then I'll make it.
> > 
> > FAM is optional.
> 
> Ok, I'll do a patch today.

[Put Ramiro in CC for approval]

The problem was the wrong assumption that g_module_build_path() would 
lookup the module for you. It does not.   

Can I commit ?


Index: libnautilus-private/nautilus-monitor.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-monitor.c,v
retrieving revision 1.11
diff -u -p -r1.11 nautilus-monitor.c
--- libnautilus-private/nautilus-monitor.c	2001/04/28 01:51:32	1.11
+++ libnautilus-private/nautilus-monitor.c	2001/06/17 11:37:14
@@ -23,6 +23,11 @@
             Darin Adler <darin eazel com>
 */
 
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+
 #include <config.h>
 #include "nautilus-monitor.h"
 
@@ -99,6 +104,75 @@ static void process_fam_notifications (g
 				       int               fd,
 				       GdkInputCondition condition);
 
+/*
+ * return a filename generated from 'dirname' & 'file'.
+ */
+static char *
+generate_filename (const char *dirname, const char *file) 
+{
+        int len;
+        char *filename;
+
+        len = strlen(dirname) + strlen(file) + 2;
+        
+        filename = malloc (len);
+        if ( ! filename ) {
+                g_error ("memory exhausted.\n");
+                return NULL;
+        }
+        
+        sprintf (filename, "%s/%s", dirname, file);
+
+        return filename;
+}
+
+static char *
+lookup_fam_library_in_directory (const char *directory) 
+{
+        int ret;
+        DIR *dir;
+        struct dirent *d;
+        char *filename = NULL;
+        
+        dir = opendir (directory);
+        if ( ! dir ) {
+                g_warning ("couldn't open %s directory.\n", directory);
+                return NULL;
+        }
+        
+        while ( (d = readdir (dir) ) ) {
+                
+                ret = strncmp (d->d_name, "libfam", 6);
+                if ( ret == 0 ) {
+                        filename = generate_filename (directory, d->d_name);
+                        break;
+                }
+        }
+
+        closedir (dir);
+
+        return filename;
+}
+
+
+static char *
+lookup_fam_library_path (void) 
+{
+        int i;
+        char *filename = NULL;
+        const char *directory[] = { "/usr/lib", "/usr/local/lib", NULL };
+
+        for ( i = 0; directory[i] != NULL; i++ ) {
+                
+                filename = lookup_fam_library_in_directory (directory[i]);
+                if ( filename )
+                        break;
+        }
+        
+        return filename;
+}
+
+
 /* singleton object, instantiate and connect if it doesn't already exist */
 static FAMConnection *
 get_fam_connection (void)
@@ -119,10 +193,14 @@ get_fam_connection (void)
 	} else {
                 tried_connection = TRUE;
 #ifdef USE_FAM_AS_MODULE
-		path = g_module_build_path (NULL, "fam");
+		path = lookup_fam_library_path ();
+                if ( ! path )
+                        return NULL;
+                
 		module = g_module_open (path, 0);
-		g_free (path);
-		if (module == NULL) {
+		free (path);
+
+                if (module == NULL) {
 			return NULL;
 		}
 		for (i = 0; i < EEL_N_ELEMENTS (fam_symbols); i++) {


-- 
Yoann Vandoorselaere | Unix IS user friendly. It's just selective about who its
MandrakeSoft         | friends are.










[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]