Adapt for running from escript (fix).

This commit is contained in:
Anton Makarov
2025-09-08 15:46:43 +03:00
parent 9a5b1625f3
commit 9b0330e01f

View File

@@ -792,6 +792,7 @@ value_to_sql(X) -> sqlite3_lib:value_to_sql(X).
-spec init([any()]) -> {'ok', #state{}} | {'stop', string()}.
init(Options) ->
PrivDir = get_priv_dir(),
io:format("PrivDir = ~p~n", [PrivDir]),
case erl_ddll:load(PrivDir, atom_to_list(?DRIVER_NAME)) of
ok ->
do_init(Options);
@@ -1075,6 +1076,8 @@ get_priv_dir() ->
case is_escript() of
{true,Escript} ->
io:format("Escript = ~p~n", [Escript]),
Which = code:which(sqlite3),
io:format("Which = ~p~n", [Which]),
{Pref,Suf} = lists:split(erlang:length(Escript), Which),
io:format("Pref = ~p~n", [Pref]),
io:format("Suf = ~p~n", [Suf]),