Make directory creation more robust

This commit is contained in:
Evgeniy Khramtsov 2014-10-02 14:05:04 +04:00
parent 6e63ee480e
commit e109f352e3
1 changed files with 1 additions and 10 deletions

View File

@ -571,16 +571,7 @@ get_dateweek(Date, Lang) ->
end).
make_dir_rec(Dir) ->
DirS = binary_to_list(Dir),
case file:read_file_info(DirS) of
{ok, _} -> ok;
{error, enoent} ->
DirL = [list_to_binary(F) || F <- filename:split(DirS)],
DirR = lists:sublist(DirL, length(DirL) - 1),
make_dir_rec(fjoin(DirR)),
file:make_dir(DirS),
file:change_mode(DirS, 8#00755) % -rwxr-xr-x
end.
filelib:ensure_dir(<<Dir/binary, $/>>).
%% {ok, F1}=file:open("valid-xhtml10.png", [read]).
%% {ok, F1b}=file:read(F1, 1000000).