Skip to content

Commit

Permalink
docstrings for dllist, dlpath (#32501) (#32507)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvwx authored and StefanKarpinski committed Jul 31, 2019
1 parent 9d4e8ae commit 927f7d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions stdlib/Libdl/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Libdl.dlsym
Libdl.dlsym_e
Libdl.dlclose
Libdl.dlext
Libdl.dllist
Libdl.dlpath
Libdl.find_library
Libdl.DL_LOAD_PATH
```
20 changes: 20 additions & 0 deletions stdlib/Libdl/src/Libdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,28 @@ end
find_library(libname::Union{Symbol,AbstractString}, extrapaths=String[]) =
find_library([string(libname)], extrapaths)

"""
dlpath(handle::Ptr{Cvoid})
Given a library `handle` from `dlopen`, return the full path.
"""
function dlpath(handle::Ptr{Cvoid})
p = ccall(:jl_pathname_for_handle, Cstring, (Ptr{Cvoid},), handle)
s = unsafe_string(p)
Sys.iswindows() && Libc.free(p)
return s
end

"""
dlpath(libname::Union{AbstractString, Symbol})
Get the full path of the library `libname`.
# Example
```julia-repl
julia> dlpath("libjulia")
```
"""
function dlpath(libname::Union{AbstractString, Symbol})
handle = dlopen(libname)
path = dlpath(handle)
Expand Down Expand Up @@ -260,6 +275,11 @@ if (Sys.islinux() || Sys.isbsd()) && !Sys.isapple()
end
end

"""
dllist()
Return the paths of dynamic libraries currently loaded in a `Vector{String}`.
"""
function dllist()
dynamic_libraries = Vector{String}()

Expand Down

0 comments on commit 927f7d8

Please sign in to comment.