backup
[makerl.git] / src / directory_hook.erl
blobb043f15becd9341f8a68fd15b1506b85129ffdd9
1 %%%-------------------------------------------------------------------
2 %%% File : compile_hook.erl
3 %%% Author : <>
4 %%% Description :
5 %%%
6 %%% Created : 25 Mar 2011 by <>
7 %%%-------------------------------------------------------------------
8 -module(directory_hook).
9 -export([get_status/3,
10 build/3]).
12 -include("makerl.hrl").
14 -spec get_status(string(), [string()], options_type()) -> status_type().
15 get_status(Target, [], Options) ->
16 Root = options:unsafe_get(Options, '*root*'),
17 Rebased = filestuff:rebase(Target, Root),
18 ?DEBUG("[Directory GetStatus] ~p~n", [Rebased]),
19 case filelib:is_dir(Rebased) of
20 true -> fulfilled;
21 _ -> unfulfilled
22 end.
24 %% If it executes, is because get_status was false --> file did not exist.
25 %% it is an error.
26 -spec build(string(), [string()], options_type()) -> build_result().
27 build(Target, [], Options) ->
28 Root = options:unsafe_get(Options, '*root*'),
29 Rebased = filename:absname(filestuff:rebase(Target, Root)),
30 ?DEBUG("[Directory Build] ~p~n", [Rebased]),
31 %% os:cmd("mkdir " ++ filename:nativename(Rebased)),
32 case filelib:ensure_dir(Rebased) of
33 ok -> {ok, Target};
34 Error -> Error
35 end.