code:priv_dir()

Bengt Kleberg eleberg@REDACTED
Wed Dec 5 16:10:05 CET 2001


> X-Authentication-Warning: avc303.etxb.ericsson.se: etxuwig owned process doing 
-bs
> Date: Wed, 5 Dec 2001 13:01:50 +0100 (MET)
> From: Ulf Wiger <etxuwig@REDACTED>
> X-X-Sender: etxuwig@REDACTED
> To: Bengt Kleberg <eleberg@REDACTED>
> cc: erlang-questions@REDACTED
> Subject: Re: code:priv_dir()
> MIME-Version: 1.0
> 
> 
> 
> The code server keeps an ets table updated with the whereabouts
> of ebin, priv, and similar directories via their parent
> directory.
> 
> 
> 1> file:make_dir("tmp").
> ok
> 2> file:make_dir("tmp/cnh2").
> ok
> 3> file:make_dir("tmp/cnh2/priv").
> ok
> 4> file:make_dir("tmp/cnh2/ebin").
> ok
> 5> code:add_path("tmp/cnh2/ebin").
> true
> 6> code:priv_dir(cnh2).
> "tmp/cnh2/priv"
> 
> 
> You can also use code:add_path("tmp/cnh2"), but it's probably
> more natural to point the code server to where the actual code
> resides. Either way, the directory that will be logged in the
> code server table (code_names, which is private and can't be
> inspected) is "tmp/cnh2".

Not beeing very well versed in Erlang I really should not pretend to
question someone that knows what he is talking about, but do you really
mean that

code:add_path("tmp/cnh2/ebin").
and
code:add_path("tmp/cnh2")

will result in the same directory beeing logged in the code server table?


Also, the manual page really should mention where, in the components of
the path, the "priv" directory is searched for.


bengt

> On Wed, 5 Dec 2001, Bengt Kleberg wrote:
> 
> >Greetings,
> >
> >Is there somebody that can expalain why the following code prints:
> >"{error, bad_name}"
> >
> >Reading the man page I would have expected
> >"tmp/cnh2/priv"
> >
> >
> >bengt
> >
> >-module(priv_dir).
> >
> >
> >-export([main/0]).
> >
> >
> >main( ) ->
> >	% ignore status, directories may already exist
> >	file:make_dir("tmp"),
> >	file:make_dir("tmp/cnh2"),
> >	file:make_dir("tmp/cnh2/priv"),
> >	% verify existance
> >	{ok, _} = file:list_dir("tmp/cnh2/priv"),
> >	true = code:add_patha("tmp"),
> >	io:format( "~w~n", [code:priv_dir("cnh2")] ).
> >
> >
> 
> -- 
> Ulf Wiger, Senior Specialist,
>    / / /   Architecture & Design of Carrier-Class Software
>   / / /    Strategic Product & System Management
>  / / /     Ericsson Telecom AB, ATM Multiservice Networks
> 




More information about the erlang-questions mailing list