Adapt for running from escript (fix 4).
This commit is contained in:
@@ -88,30 +88,24 @@ init() ->
|
||||
|
||||
%% @private
|
||||
get_priv_dir() ->
|
||||
PrivDir = code:priv_dir(esqlite),
|
||||
io:format("PrivDir = code:priv_dir(esqlite) = ~p~n", [PrivDir]),
|
||||
case PrivDir of
|
||||
%case code:priv_dir(esqlite) of
|
||||
{error, bad_name} ->
|
||||
%% application isn't in path, fall back
|
||||
case is_escript() of
|
||||
{true,Escript} ->
|
||||
io:format("Escript = ~p~n", [Escript]),
|
||||
Which = code:which(esqlite),
|
||||
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]),
|
||||
RootDir = filename:dirname(filename:dirname(Pref)),
|
||||
AppsDir = filename:join(RootDir, "lib"),
|
||||
io:format("AppsDir = ~p~n", [AppsDir]),
|
||||
SqDir = filename:dirname(filename:dirname(Suf)),
|
||||
filename:join([AppsDir, [$.|SqDir], "priv"]); % prepend "." to suffix that starts with "/"
|
||||
false ->
|
||||
"priv"
|
||||
end;
|
||||
Dir ->
|
||||
Dir
|
||||
case is_escript() of
|
||||
{true,Escript} ->
|
||||
io:format("Escript = ~p~n", [Escript]),
|
||||
Which = code:which(esqlite),
|
||||
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]),
|
||||
RootDir = filename:dirname(filename:dirname(Pref)),
|
||||
AppsDir = filename:join(RootDir, "lib"),
|
||||
io:format("AppsDir = ~p~n", [AppsDir]),
|
||||
SqDir = filename:dirname(filename:dirname(Suf)),
|
||||
filename:join([AppsDir, [$.|SqDir], "priv"]); % prepend "." to suffix that starts with "/"
|
||||
false ->
|
||||
case code:priv_dir(esqlite) of
|
||||
{error, bad_name} -> "priv";
|
||||
Dir -> Dir
|
||||
end
|
||||
end.
|
||||
|
||||
%% @private
|
||||
|
||||
Reference in New Issue
Block a user