summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuncer Ayaz <tuncer.ayaz@gmail.com>2012-06-14 23:59:36 +0200
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2012-06-14 23:59:36 +0200
commite65455b6ef0d7473e7cca3373cb65c4e11541318 (patch)
tree41b1f42e88bbfab3ccd0568a91eb7836daf3ba91
parent1e980859e2ecf0ee0fb2036b3a35496492246d55 (diff)
Simplify temp dir creation
-rw-r--r--src/rebar_escripter.erl27
1 files changed, 7 insertions, 20 deletions
diff --git a/src/rebar_escripter.erl b/src/rebar_escripter.erl
index 7a5fb8b..16c2f20 100644
--- a/src/rebar_escripter.erl
+++ b/src/rebar_escripter.erl
@@ -95,32 +95,19 @@ clean(Config, AppFile) ->
%% ===================================================================
make_temp_dir(AppName) ->
- case temp_name(AppName ++ ".") of
- {ok, TempDir} ->
- case file:make_dir(TempDir) of
- ok ->
- TempDir;
- Error ->
- ?ABORT("Failed to create temporary directory: ~p~n",
- [Error])
- end;
+ TempDir = temp_name(AppName ++ "."),
+ case file:make_dir(TempDir) of
+ ok ->
+ ?CONSOLE("TempDir: ~p~n", [TempDir]),
+ TempDir;
Error ->
?ABORT("Failed to create temporary directory: ~p~n",
[Error])
end.
temp_name(Prefix) ->
- temp_name(Prefix, 5).
-
-temp_name(_Prefix, 0) ->
- {error, eexist};
-temp_name(Prefix, N) ->
Hash = erlang:phash2(make_ref()),
- Name = Prefix ++ integer_to_list(Hash),
- case filelib:is_file(Name) of
- false -> {ok, Name};
- true -> temp_name(Prefix, N-1)
- end.
+ Prefix ++ integer_to_list(Hash).
copy_files(Config, AppName, Temp) ->
BaseEbinDir = filename:join(AppName, "ebin"),
@@ -157,7 +144,7 @@ get_app_ebin_dirs([App | Rest], Acc) ->
"~p escript_incl_apps.", [App]);
Path ->
%% TODO: shouldn't we also include .app files? escript
- %% supports multiple app files in one ebin/
+ %% should support multiple app files in one ebin/
Acc2 = filename:join(Path, "*.beam"),
get_app_ebin_dirs(Rest, [Acc2|Acc])
end.