Permalink
Browse files

Works both when packed to ez and when used raw.

  • Loading branch information...
1 parent af8b361 commit be946a5f38b9acfecd9679561a54d78ecdfdbe26 @RGafiyatullin RGafiyatullin committed Mar 11, 2012
Showing with 15 additions and 2 deletions.
  1. +15 −2 src/procket.erl
View
@@ -72,6 +72,7 @@ on_load() ->
erlang:load_nif(progname(), []).
+
close(_) ->
erlang:error(not_implemented).
@@ -272,8 +273,13 @@ is_device(Name) when is_list(Name) ->
Name == [C || C <- Name, ((C >= $a) and (C =< $z))
or ((C >= $0) and (C =< $9) or (C == $/))].
-progname() ->
- % Is there a proper way of getting App-Name in this context?
+progname_ebin() ->
+ filename:join([
+ filename:dirname( code:which( ?MODULE ) ),
+ "..", "priv", ?MODULE
+ ]).
+
+progname_priv() ->
case application:get_env( ?MODULE, port_executable ) of
{ok, Executable} -> Executable;
undefined -> filename:join([
@@ -282,6 +288,13 @@ progname() ->
])
end.
+progname() ->
+ % Is there a proper way of getting App-Name in this context?
+ case code:priv_dir( ?MODULE ) of
+ {error,bad_name} -> progname_ebin();
+ ________________ -> progname_priv()
+ end.
+
%% Protocol family (aka domain)
family(unspec) -> 0;
family(inet) -> 2;

0 comments on commit be946a5

Please sign in to comment.