Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
handled loading of NIF when the library is in lib_dir of an embedded …
…node
  • Loading branch information
mrinalwadhwa committed Apr 29, 2010
1 parent b2a0286 commit b44de68ed884436efbdf4cd46f5a3512d300df4b
Showing 1 changed file with 15 additions and 7 deletions.
@@ -37,13 +37,21 @@
%% @end
%%--------------------------------------------------------------------
init() ->
NIF = filename:join([
filename:dirname(code:which(?MODULE)),
"..",
"priv",
?MODULE
]) ++ "_drv",
erlang:load_nif(NIF, 0).
Path = filename:join([filename:dirname(code:which(?MODULE)),"..","priv",?MODULE]) ++ "_drv",
case filelib:is_file(Path ++ ".so") of
true -> erlang:load_nif(Path, 0);
false ->
Path1 = filename:join([code:lib_dir(),"erlang-bcrypt","priv",?MODULE]) ++ "_drv",
case filelib:is_file(Path1 ++ ".so") of
true -> erlang:load_nif(Path1, 0);
false ->
Path2 = filename:join([code:lib_dir(),"bcrypt","priv",?MODULE]) ++ "_drv",
case filelib:is_file(Path2 ++ ".so") of
true -> erlang:load_nif(Path2, 0);
false -> exit({could_not_find_nif, module, ?MODULE, line, ?LINE})
end
end
end.

%%--------------------------------------------------------------------
%% @doc Generate a salt with the default number of rounds, 12.

0 comments on commit b44de68

Please sign in to comment.