diff options
author | Eric <[email protected]> | 2012-12-28 10:21:37 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-12-28 10:21:37 -0500 |
commit | b5b6cf855b3bceaac76ccd330d64cfeb2b1f4c14 (patch) | |
tree | 212b87d6cd151fa1e8eca6ce7d28a49eeb6d3569 /src/rcl_prv_overlay.erl | |
parent | 8c22ae33056a406fe2baf180d16e3fb090638508 (diff) | |
download | relx-b5b6cf855b3bceaac76ccd330d64cfeb2b1f4c14.tar.gz relx-b5b6cf855b3bceaac76ccd330d64cfeb2b1f4c14.tar.bz2 relx-b5b6cf855b3bceaac76ccd330d64cfeb2b1f4c14.zip |
make directory checking more robust
Diffstat (limited to 'src/rcl_prv_overlay.erl')
-rw-r--r-- | src/rcl_prv_overlay.erl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/rcl_prv_overlay.erl b/src/rcl_prv_overlay.erl index 160629b..9670138 100644 --- a/src/rcl_prv_overlay.erl +++ b/src/rcl_prv_overlay.erl @@ -289,11 +289,11 @@ do_individual_overlay(State, OverlayVars, {template, From, To}) -> copy_to(State, FromFile0, ToFile0) -> ToFile1 = absolutize(State, ToFile0), FromFile1 = absolutize(State, FromFile0), - ToFile2 = case re:run(ToFile0, ?DIRECTORY_RE) of - nomatch -> + ToFile2 = case is_directory(ToFile0, ToFile1) of + false -> filelib:ensure_dir(ToFile1), ToFile1; - _ -> + true -> rcl_util:mkdir_p(ToFile1), erlang:iolist_to_binary(filename:join(ToFile1, filename:basename(FromFile1))) @@ -307,6 +307,16 @@ copy_to(State, FromFile0, ToFile0) -> ToFile1, Err}) end. +-spec is_directory(file:name(), file:name()) -> boolean(). +is_directory(ToFile0, ToFile1) -> + case re:run(ToFile0, ?DIRECTORY_RE) of + nomatch -> + filelib:is_dir(ToFile1); + _ -> + true + end. + + -spec render_template(proplists:proplist(), iolist()) -> ok | relcool:error(). render_template(OverlayVars, Data) -> |