Seems to work
[makerl.git] / src / mkrl_utils.erl
blobe600adf080b37fadb3dfda51a1229db6d524623c
1 %%%-------------------------------------------------------------------
2 %%% File : utils.erl
3 %%% Author : <>
4 %%% Description :
5 %%%
6 %%% Created : 14 Apr 2011 by <>
7 %%%-------------------------------------------------------------------
8 -module(mkrl_utils).
9 -export([mkdir/1,
10 file_out/2,
11 delayed_apply/3]).
13 -spec mkdir(string()) -> boolean().
14 mkdir(Dir) ->
15 case os:type() of
16 {win32, _} ->
17 os:cmd("mkdir " ++ filename:nativename(Dir));
18 _ ->
19 filelib:ensure_dir(Dir)
20 end,
21 filelib:is_dir(Dir).
23 -spec file_out([term()], string()) -> ok | {error, any()}.
24 file_out(Terms, OutputFile) ->
25 {ok, Io} = file:open(OutputFile, [ write ]),
26 lists:foreach(fun(SynTask) ->
27 file:write(Io, io_lib:fwrite("~p.\n", [SynTask]))
28 end,
29 Terms).
32 -spec delayed_apply(integer(), fun(), [term()]) -> any().
33 delayed_apply(Milli, F, Args) ->
34 timer:sleep(Milli),
35 apply(F, Args).