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)
This commit is contained in:
Bryan Fink 2010-02-04 17:45:05 -05:00
parent 4c2dade0f4
commit 60629e8516

View file

@ -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) ->