Adding delete_each/1

This commit is contained in:
Dave Smith 2009-12-01 10:37:19 -07:00
parent 667dd16bf9
commit b3909cc9dc

View file

@ -27,7 +27,8 @@
-export([rm_rf/1, -export([rm_rf/1,
mkdir_p/1, mkdir_p/1,
cp_r/2, cp_r/2,
ln_sf/2]). ln_sf/2,
delete_each/1]).
-include("rebar.hrl"). -include("rebar.hrl").
@ -58,3 +59,16 @@ ln_sf(Source, Dest) ->
[] = os:cmd(?FMT("ln -sf ~s ~s", [Source, Dest])), [] = os:cmd(?FMT("ln -sf ~s ~s", [Source, Dest])),
ok. ok.
delete_each([]) ->
ok;
delete_each([File | Rest]) ->
case file:delete(File) of
ok ->
delete_each(Rest);
{error, enoent} ->
delete_each(Rest);
{error, Reason} ->
?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
?FAIL
end.