code:priv_dir()
Vance Shipley
vances@REDACTED
Wed Dec 5 18:04:07 CET 2001
> 4> code:add_path("tmp/cnh2").
> true
> 5> code:priv_dir(cnh2).
> "tmp/cnh2/priv"
The documentation for code:priv_dir/1 explicitly says that you
will get "/priv" appended to the directory name. What you will
get out this function is the full, possibly expanded, name of
the priv directory.
1> file:make_dir("tmp").
ok
2> file:make_dir("tmp/cnh2-3.4.5").
ok
3> code:add_path("tmp/cnh2-3.4.5").
true
4> code:priv_dir(cnh2).
"tmp/cnh2-3.4.5/priv"
It doesn't even have to exist!
priv_dir(Name) -> PrivDir | {error, What}
This function returns the current priv directory for the
Name[-*] directory. The current path is searched for a
directory named .../Name-* (the -* suffix is optional for
directories in the search path and it represents the version
of the directory). The /priv suffix is added to the end of
the found directory.
The thing to realize is that the priv directory is for storing data.
We put some of our mnesia tables there (if they're small enough).
The ebin directory is where your .beam files belong. You want to add
"tmp/cnh2-3.4.5/ebin" directory to the path. If you later want to
find out what the path name to the cnh2 data files is you run:
4> code:priv_dir(cnh2).
"tmp/cnh2-3.4.5/priv"
And you find out the full path including any trailing version numbers.
The directory structures is documented in:
http://www.erlang.org/doc/r8b/lib/sasl-1.9.3/doc/html/part_frame.html
A release should be divided into the following directories:
$ROOTDIR/lib/App1-AVsn1/ebin
/priv
/App2-AVsn2/ebin
/priv
...
/AppN-AVsnN/ebin
/priv
/erts-EVsn/bin
/releases/Vsn
/bin
The ebin directory contains the Erlang object code and the
application resource file.
The priv directory contains any application private data.
Specifically, port programs should be located in the priv directory.
The priv directory of an application is found by a call to
code:priv_dir(AppName).
-Vance
Vance Shipley
Motivity Telecom Inc.
+1 519 579 5816
More information about the erlang-questions
mailing list