summaryrefslogtreecommitdiff
path: root/src/rebar_file_utils.erl
diff options
context:
space:
mode:
authorTristan Sloughter <tristan.sloughter@gmail.com>2015-03-02 19:04:03 -0600
committerTristan Sloughter <tristan.sloughter@gmail.com>2015-03-02 19:04:03 -0600
commitbaf46a861b18086131707d056ee106c9fba8da3d (patch)
treec0bc1de343e52f8385d9f1740e32df5e85dfa234 /src/rebar_file_utils.erl
parent8affde1c37ba746df41343a52fd8e239ebfe2db3 (diff)
parentaf0f4bb20a66f1464fa25d31f9b69784f3119493 (diff)
Merge pull request #187 from tsloughter/profiles_dir
make base_dir for a run include the profiles in path, link to shared dep
Diffstat (limited to 'src/rebar_file_utils.erl')
-rw-r--r--src/rebar_file_utils.erl21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl
index 8fe8965..ef2c70f 100644
--- a/src/rebar_file_utils.erl
+++ b/src/rebar_file_utils.erl
@@ -26,7 +26,8 @@
%% -------------------------------------------------------------------
-module(rebar_file_utils).
--export([rm_rf/1,
+-export([symlink_or_copy/2,
+ rm_rf/1,
cp_r/2,
mv/2,
delete_each/1,
@@ -41,6 +42,22 @@
%% Public API
%% ===================================================================
+symlink_or_copy(Source, Target) ->
+ Link = case os:type() of
+ {win32, _} ->
+ Source;
+ _ ->
+ rebar_dir:make_relative_path(Source, Target)
+ end,
+ case file:make_symlink(Link, Target) of
+ ok ->
+ ok;
+ {error, eexist} ->
+ ok;
+ {error, _} ->
+ cp_r([Source], Target)
+ end.
+
%% @doc Remove files and directories.
%% Target is a single filename, directoryname or wildcard expression.
-spec rm_rf(string()) -> 'ok'.
@@ -127,7 +144,7 @@ write_file_if_contents_differ(Filename, Bytes) ->
end.
%% returns an os appropriate tmpdir given a path
--spec system_tmpdir() -> file:filename().
+-spec system_tmpdir() -> file:filename().
-spec system_tmpdir(PathComponents) -> file:filename() when
PathComponents :: [file:name()].