aboutsummaryrefslogtreecommitdiffstats
path: root/src/rcl_util.erl
diff options
context:
space:
mode:
authorEric <[email protected]>2012-09-04 16:25:25 -0500
committerEric <[email protected]>2012-09-08 11:14:55 -0500
commitd3debef8d90735087425f7ad03da4010d636d6a7 (patch)
treef4f4ccc4b23017b5c6193959973248052fd96c5c /src/rcl_util.erl
parent13263b778c4f519e27629a2e0772b2466004005b (diff)
downloadrelx-d3debef8d90735087425f7ad03da4010d636d6a7.tar.gz
relx-d3debef8d90735087425f7ad03da4010d636d6a7.tar.bz2
relx-d3debef8d90735087425f7ad03da4010d636d6a7.zip
add a utility file to the system with an inital mkdir_p option
Diffstat (limited to 'src/rcl_util.erl')
-rw-r--r--src/rcl_util.erl51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/rcl_util.erl b/src/rcl_util.erl
new file mode 100644
index 0000000..c0b5c5d
--- /dev/null
+++ b/src/rcl_util.erl
@@ -0,0 +1,51 @@
+%% -*- mode: Erlang; fill-column: 80; comment-column: 75; -*-
+%%% Copyright 2012 Erlware, LLC. All Rights Reserved.
+%%%
+%%% This file is provided to you under the Apache License,
+%%% Version 2.0 (the "License"); you may not use this file
+%%% except in compliance with the License. You may obtain
+%%% a copy of the License at
+%%%
+%%% http://www.apache.org/licenses/LICENSE-2.0
+%%%
+%%% Unless required by applicable law or agreed to in writing,
+%%% software distributed under the License is distributed on an
+%%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+%%% KIND, either express or implied. See the License for the
+%%% specific language governing permissions and limitations
+%%% under the License.
+%%%---------------------------------------------------------------------------
+%%% @author Eric Merritt <[email protected]>
+%%% @copyright (C) 2012 Erlware, LLC.
+%%%
+%%% @doc Trivial utility file to help handle common tasks
+-module(rcl_util).
+
+-export([mkdir_p/1]).
+
+%%============================================================================
+%% types
+%%============================================================================
+
+
+%%============================================================================
+%% API
+%%============================================================================
+%% @doc Makes a directory including parent dirs if they are missing.
+-spec mkdir_p(string()) -> ok | {error, Reason::file:posix()}.
+mkdir_p(Path) ->
+ %% We are exploiting a feature of ensuredir that that creates all
+ %% directories up to the last element in the filename, then ignores
+ %% that last element. This way we ensure that the dir is created
+ %% and not have any worries about path names
+ DirName = filename:join([filename:absname(Path), "tmp"]),
+ filelib:ensure_dir(DirName).
+
+%%%===================================================================
+%%% Test Functions
+%%%===================================================================
+
+-ifndef(NOTEST).
+-include_lib("eunit/include/eunit.hrl").
+
+-endif.