summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Fink <bryan@basho.com>2010-02-04 17:45:05 -0500
committerBryan Fink <bryan@basho.com>2010-02-04 17:45:05 -0500
commit60629e85162110e750b986a1531ce0594e75bd3f (patch)
tree759c6e33aecd7b2744952776c08c5f8a6f5dca71
parent4c2dade0f42169309b742fa13715ef92f2aa70fb (diff)
add chmod template directive for changing file file permission
usage: {chmod, Mode, File} where: Mode is an integer, as specified by the 'mode' field of the file_info record (see docs for file:write_file_info/2)
-rw-r--r--src/rebar_templater.erl8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 7a21e7d..9e2971c 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -254,6 +254,14 @@ execute_template([{dir, Name} | Rest], TemplateType, TemplateName, Context, Forc
?ABORT("Failed while processing template instruction {dir, ~s}: ~p\n",
[Name, Reason])
end;
+execute_template([{chmod, Mod, File} | Rest], TemplateType, TemplateName, Context, Force, ExistingFiles) when is_integer(Mod) ->
+ case file:change_mode(File, Mod) of
+ ok ->
+ execute_template(Rest, TemplateType, TemplateName, Context, Force, ExistingFiles);
+ {error, Reason} ->
+ ?ABORT("Failed while processing template instruction {cmod, ~b, ~s}: ~p~n",
+ [Mod, File, Reason])
+ end;
execute_template([{variables, _} | Rest], TemplateType, TemplateName, Context, Force, ExistingFiles) ->
execute_template(Rest, TemplateType, TemplateName, Context, Force, ExistingFiles);
execute_template([{file, Input, Output} | Rest], TemplateType, TemplateName, Context, Force, ExistingFiles) ->