サンプル作った。
サンプル:
-module(setcwdTest).
-export([start/0]).
%% please create directory "zip_work" on current directory.
%% this program create directory "setcwdTest" on "zip_work".
%% warning : if you execute this program on EShell,
%% Current directory at EShell exchange to "zip_work"
%% directory.
start() ->
case file:get_cwd() of
{ok,Cwd} ->
io:format("Currnet:~p~n",[Cwd]),
SetCwd = "zip_work",
setTest(SetCwd);
{error,Reason} ->
io:format("Error:~p~n",[Reason]),
error
end.
setTest(Cwd) ->
try
case file:set_cwd(Cwd) of
ok -> file:make_dir("setcwdTest");
{error,Reason} -> io:format("set_cwd Error:~p~n",[Reason])
end
catch
_ -> io:format("setTest throw exception~n")
end.