#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Thu, 15 Sep 2016 13:04:28 +0200
changeset 20390 57faf25b3d15
parent 20389 1104e43dbe9c
child 20391 beea43e4a428
#REFACTORING by stefan class: ExternalLibraryFunction changed: #loadLibrary:
ExternalLibraryFunction.st
--- a/ExternalLibraryFunction.st	Thu Sep 15 09:36:40 2016 +0200
+++ b/ExternalLibraryFunction.st	Thu Sep 15 13:04:28 2016 +0200
@@ -922,11 +922,11 @@
      This is useful, if some code has a hardcoded dll-name in it, which needs to be changed,
      but you do not want or cannot recompile the methods (i.e. no source avail)"
 
-    |handle nameString filename|
+    |handle nameString filename dllPathes|
 
     filename := dllName.
     DllMapping notNil ifTrue:[
-	filename := DllMapping at:filename ifAbsent:[ filename ]
+        filename := DllMapping at:filename ifAbsent:[ filename ]
     ].
 
     filename := filename asFilename.
@@ -937,25 +937,25 @@
     handle notNil ifTrue:[^ handle ].
 
     filename isAbsolute ifFalse:[
-	"First ask the class defining the ExternalFunction for the location of the dlls ..."
-	owningClass notNil ifTrue:[
-	    owningClass dllPath do:[:eachDirectory |
-		handle := ObjectFileLoader
-			    loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
-		handle notNil ifTrue:[^ handle ].
-	    ].
-	].
-	".. then ask the system"
-	self class dllPath do:[:eachDirectory |
-	    handle := ObjectFileLoader
-			loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName.
-	    handle notNil ifTrue:[^ handle ].
-	].
+        "First ask the class defining the ExternalFunction for the location of the dlls ..."
+        dllPathes := #().
+        owningClass notNil ifTrue:[
+            dllPathes := owningClass dllPath.
+        ].
+        ".. then ask the system"
+        dllPathes := dllPathes, self class dllPath.
+        dllPathes do:[:eachDirectory |
+            |libraryName|
+
+            libraryName := eachDirectory asFilename construct:nameString.
+            handle := ObjectFileLoader loadDynamicObject:libraryName.
+            handle notNil ifTrue:[^ handle ].
+        ].
     ].
 
     filename suffix isEmpty ifTrue:[
-	"/ try again with the OS-specific dll-extension
-	^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
+        "/ try again with the OS-specific dll-extension
+        ^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix)
     ].
 
     ^ nil