Skip to content

Is there a better way to determine if a library is installed on the system? #225

Answered by basshelal
basshelal asked this question in Q&A
Discussion options

You must be logged in to vote

I found a solution to my specific use case for anyone curious about how to solve this, but I still think JNR should have this feature in some way without having to load the library or letting callers have to do tedious file checks like I have done.

It's in Kotlin, but the idea comes across, essentially I'm just searching to see if the library (in this case JACK, ie libjack) is in any of its expected locations, in which case I can assume it's installed.

/** `true` if *any* of the passed in [paths] refers to an existing file, `false` otherwise */
@Suppress("NOTHING_TO_INLINE")
private inline fun anyFileExists(paths: Iterable<String>): Boolean = paths.any { path: String ->
    File(path).let

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@headius
Comment options

Answer selected by basshelal
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants