設置Erlang裝載代碼的路徑

2009-04-26
code:get_path() 查看當前的裝載路徑:
code:get_path().
["ebin",".","/usr/local/lib/erlang/lib/kernel-2.12.5/ebin",
"/usr/local/lib/erlang/lib/stdlib-1.15.5/ebin",
"/usr/local/lib/erlang/lib/xmerl-1.1.10/ebin",
"/usr/local/lib/erlang/lib/webtool-0.8.3.2/ebin",
"/usr/local/lib/erlang/lib/typer-0.1.5/ebin",
"/usr/local/lib/erlang/lib/tv-2.1.4.2/ebin",
"/usr/local/lib/erlang/lib/tools-2.6.2/ebin",
"/usr/local/lib/erlang/lib/toolbar-1.3.0.1/ebin",
"/usr/local/lib/erlang/lib/test_server-3.2.4/ebin",
"/usr/local/lib/erlang/lib/syntax_tools-1.5.6/ebin",
"/usr/local/lib/erlang/lib/ssl-3.10/ebin",
"/usr/local/lib/erlang/lib/ssh-1.0.2/ebin",
[...]|...]


code:add_patha(Dir) -> true | {error, bad_directory}
添加新目錄Dir到裝載路徑列表的開頭

code:add_pathz(Dir) -> true | {error, bad_directory}
添加新目錄Dir到裝載路徑列表的尾部

如果怀疑裝載了錯誤的模塊,可以調用函數code:all_loaded()查看所有己加載的模塊列表,或者調用code:clash()

也可以在啟動Erlang的時候指定代碼載入路徑:
> erl -pa Dir1 -pa Dir2 ... -pz DirK1 -pz DirK2

其中-pa將目錄添加到搜索路徑的開頭,而-pz則把目錄加到路徑的末尾~~

M-OSCAR | Powered by Blogger | Entries (RSS) | Comments (RSS) | Designed by MB Web Design | XML Coded By Cahayabiru.com