From 9bb923c02fc458a94c6be63124a6956766161520 Mon Sep 17 00:00:00 2001 From: James Lee Date: Sat, 26 Feb 2011 01:32:42 -0500 Subject: [PATCH] Use code:priv_dir/1 to find driver location without guessing around. --- src/bcrypt.erl | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/bcrypt.erl b/src/bcrypt.erl index 58184b2..2a65f35 100644 --- a/src/bcrypt.erl +++ b/src/bcrypt.erl @@ -37,21 +37,7 @@ %% @end %%-------------------------------------------------------------------- init() -> - Path = filename:join([filename:dirname(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. + erlang:load_nif(filename:join(code:priv_dir(?MODULE), atom_to_list(?MODULE) ++ "_drv"), 0). %%-------------------------------------------------------------------- %% @doc Generate a salt with the default number of rounds, 12.