libs/wine: improve bin directory detection on FreeBSD

Damjan Jovanovic damjan.jov at gmail.com
Sun Jun 3 05:26:30 CDT 2012


Changelog:
* improve bin directory detection on FreeBSD

Damjan Jovanovic
-------------- next part --------------
diff --git a/libs/wine/config.c b/libs/wine/config.c
index 035c268..6a97f90 100644
--- a/libs/wine/config.c
+++ b/libs/wine/config.c
@@ -151,12 +151,18 @@ static char *get_runtime_bindir( const char *argv0 )
     char *p, *bindir, *cwd;
     int len, size;
 
-#ifdef linux
+#if defined (linux)
+#define EXE_LINK "/proc/self/exe"
+#elif defined (__FreeBSD__)
+#define EXE_LINK "/proc/curproc/file"
+#endif
+
+#if defined (EXE_LINK)
     for (size = 256; ; size *= 2)
     {
         int ret;
         if (!(bindir = malloc( size ))) break;
-        if ((ret = readlink( "/proc/self/exe", bindir, size )) == -1) break;
+        if ((ret = readlink( EXE_LINK, bindir, size )) == -1) break;
         if (ret != size)
         {
             if (!(p = memrchr( bindir, '/', ret ))) break;
@@ -167,6 +173,7 @@ static char *get_runtime_bindir( const char *argv0 )
         free( bindir );
     }
     free( bindir );
+#undef EXE_LINK
 #endif
 
     if (!(p = strrchr( argv0, '/' ))) return NULL;


More information about the wine-patches mailing list