[chronojump] Fix library loading in windows



commit b3a741f89c321c98b7a98ba9a683edfb17516278
Author: Windows Build <windows chronojump org>
Date:   Sun Feb 9 22:45:46 2014 +0100

    Fix library loading in windows

 rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs b/rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs
index 9cca9f3..2581c02 100644
--- a/rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs
+++ b/rdotnet/RDotNet.NativeLibrary/UnmanagedDll.cs
@@ -34,7 +34,7 @@ namespace RDotNet.NativeLibrary
                                throw new ArgumentException("dllName");
                        }
 
-                       IntPtr handle = LoadLibrary(dllName);
+                       IntPtr handle = IntLoadLibrary(dllName);
                        if (handle == IntPtr.Zero)
                        {
                                throw new DllNotFoundException();
@@ -169,17 +169,15 @@ namespace RDotNet.NativeLibrary
 #endif
 
 #if UNIX
-               private static IntPtr LoadLibrary(string filename)
+               private static IntPtr IntLoadLibrary(string filename)
                {
                        const int RTLD_LAZY = 0x1;
                        if (filename.StartsWith("/"))
                        {
                                return dlopen(filename, RTLD_LAZY);
                        }
-                       Console.WriteLine (filename); 
                        var searchPaths = (Environment.GetEnvironmentVariable("PATH") ?? 
"").Split(Path.PathSeparator);
                        var dll = searchPaths.Select(directory => Path.Combine(directory, 
filename)).FirstOrDefault(File.Exists);
-                       Console.WriteLine (dll); 
                        return dll == null ? IntPtr.Zero : dlopen(dll, RTLD_LAZY);
                }
                
@@ -188,6 +186,13 @@ namespace RDotNet.NativeLibrary
 #else
                [DllImport("kernel32.dll")]
                private static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
+
+               private static IntPtr IntLoadLibrary(string filename)
+               {
+                       var searchPaths = (Environment.GetEnvironmentVariable("PATH") ?? 
"").Split(Path.PathSeparator);
+                       var dll = searchPaths.Select(directory => Path.Combine(directory, 
filename)).FirstOrDefault(File.Exists);
+                       return dll == null ? IntPtr.Zero : LoadLibrary(dll);
+               }
 #endif
 
 #if UNIX


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