/
FFILibraryFinder.class.st
59 lines (44 loc) · 1.31 KB
/
FFILibraryFinder.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"
I'm a tool to find paths in diverse platforms (since they have the tendency of put its libraries in diferent places).
You do not use FFILibraryFinder directly, but one of my children.
Example:
FFIUnix64LibraryFinder findLibrary: 'libcairo.2.so'
"
Class {
#name : #FFILibraryFinder,
#superclass : #Object,
#category : #'UnifiedFFI-Libraries'
}
{ #category : #accessing }
FFILibraryFinder class >> findLibrary: aName [
^ self new findLibrary: aName
]
{ #category : #accessing }
FFILibraryFinder >> basePaths [
^ self subclassResponsibility
]
{ #category : #accessing }
FFILibraryFinder >> findLibrary: aString [
self paths do: [ :each | | path |
path := each / aString.
path exists
ifTrue: [ ^ path fullName ] ].
self error: ('Cannot locate {1}. Please check if it installed on your system' format: { aString })
]
{ #category : #accessing }
FFILibraryFinder >> knownPaths [
^ self subclassResponsibility
]
{ #category : #accessing }
FFILibraryFinder >> ldLibraryPaths [
^ (OSEnvironment current at: 'LD_LIBRARY_PATH' ifAbsent: [ '' ]) substrings: ':'
]
{ #category : #accessing }
FFILibraryFinder >> paths [
^ (Array streamContents: [ :stream |
stream
nextPutAll: self basePaths;
nextPutAll: self ldLibraryPaths;
nextPutAll: self knownPaths ])
collect: [ :each | each asFileReference ]
]