code:priv_dir()

Ulf Wiger etxuwig@REDACTED
Wed Dec 5 13:01:50 CET 2001



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".

/Uffe


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