summaryrefslogtreecommitdiff
path: root/src/rebar_utils.erl
diff options
context:
space:
mode:
authorDave Smith <dizzyd@dizzyd.com>2009-11-30 16:03:45 -0700
committerDave Smith <dizzyd@dizzyd.com>2009-11-30 16:03:45 -0700
commitc7c1001012831eb06957b147ee3e5424c0ab2c77 (patch)
tree84616addc000805658c6ee6af12f0a9e52ccb579 /src/rebar_utils.erl
parent961c95b419ca0aa1e1c8ff6520450fe8e3368de5 (diff)
Slowly working out port driver implementation
Diffstat (limited to 'src/rebar_utils.erl')
-rw-r--r--src/rebar_utils.erl32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index 92f40ec..d3717cc 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -24,9 +24,39 @@
%% -------------------------------------------------------------------
-module(rebar_utils).
--export([get_cwd/0]).
+-export([get_cwd/0,
+ get_os/0]).
+
+
+%% ====================================================================
+%% Public API
+%% ====================================================================
get_cwd() ->
{ok, Dir} = file:get_cwd(),
Dir.
+
+get_os() ->
+ Arch = erlang:system_info(system_architecture),
+ case match_first([{"linux", linux}, {"darwin", darwin}], Arch) of
+ nomatch ->
+ {unknown, Arch};
+ ArchAtom ->
+ ArchAtom
+ end.
+
+
+%% ====================================================================
+%% Internal functions
+%% ====================================================================
+
+match_first([], Val) ->
+ nomatch;
+match_first([{Regex, MatchValue} | Rest], Val) ->
+ case re:run(Val, Regex, [{capture, none}]) of
+ match ->
+ MatchValue;
+ nomatch ->
+ match_first(Rest, Val)
+ end.