From b3909cc9dc308b26cfd98b048944a99a57eee560 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Tue, 1 Dec 2009 10:37:19 -0700 Subject: [PATCH] Adding delete_each/1 --- src/rebar_file_utils.erl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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.