diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2009-12-01 10:37:19 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2009-12-01 10:37:19 -0700 |
commit | b3909cc9dc308b26cfd98b048944a99a57eee560 (patch) | |
tree | 635ea974a5fa73efb3a216e2616c46e25af4dc7d | |
parent | 667dd16bf9d2cdb848e3e624f2bb6295770460b7 (diff) |
Adding delete_each/1
-rw-r--r-- | src/rebar_file_utils.erl | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index 60b6a59..8d21323 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -27,7 +27,8 @@ -export([rm_rf/1, mkdir_p/1, cp_r/2, - ln_sf/2]). + ln_sf/2, + delete_each/1]). -include("rebar.hrl"). @@ -57,4 +58,17 @@ ln_sf(Source, Dest) -> end, [] = os:cmd(?FMT("ln -sf ~s ~s", [Source, Dest])), 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. |