Merge pull request #37 from ericbmerritt/next
make ec_file a bit more friendly to binary file names
This commit is contained in:
commit
d78358af0b
2 changed files with 14 additions and 7 deletions
|
@ -1,5 +1,6 @@
|
||||||
language: erlang
|
language: erlang
|
||||||
otp_release:
|
otp_release:
|
||||||
|
- R16B
|
||||||
- R15B02
|
- R15B02
|
||||||
- R15B01
|
- R15B01
|
||||||
- R15B
|
- R15B
|
||||||
|
|
|
@ -241,7 +241,8 @@ find_in_subdirs(FromDir, TargetPattern) ->
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
[],
|
[],
|
||||||
filelib:wildcard(filename:join(FromDir, "*"))).
|
sub_files(FromDir)).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-spec remove_recursive(file:name(), Options::list()) -> ok | {error, Reason::term()}.
|
-spec remove_recursive(file:name(), Options::list()) -> ok | {error, Reason::term()}.
|
||||||
|
@ -252,7 +253,7 @@ remove_recursive(Path, Options) ->
|
||||||
true ->
|
true ->
|
||||||
lists:foreach(fun(ChildPath) ->
|
lists:foreach(fun(ChildPath) ->
|
||||||
remove_recursive(ChildPath, Options)
|
remove_recursive(ChildPath, Options)
|
||||||
end, filelib:wildcard(filename:join(Path, "*"))),
|
end, sub_files(Path)),
|
||||||
file:del_dir(Path)
|
file:del_dir(Path)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -273,7 +274,7 @@ copy_subfiles(From, To, Options) ->
|
||||||
ChildTo = filename:join([To, filename:basename(ChildFrom)]),
|
ChildTo = filename:join([To, filename:basename(ChildFrom)]),
|
||||||
copy(ChildFrom, ChildTo, Options)
|
copy(ChildFrom, ChildTo, Options)
|
||||||
end,
|
end,
|
||||||
lists:foreach(Fun, filelib:wildcard(filename:join(From, "*"))).
|
lists:foreach(Fun, sub_files(From)).
|
||||||
|
|
||||||
-spec make_dir_if_dir(file:name()) -> ok | {error, Reason::term()}.
|
-spec make_dir_if_dir(file:name()) -> ok | {error, Reason::term()}.
|
||||||
make_dir_if_dir(File) ->
|
make_dir_if_dir(File) ->
|
||||||
|
@ -299,6 +300,10 @@ hex0(14) -> $e;
|
||||||
hex0(15) -> $f;
|
hex0(15) -> $f;
|
||||||
hex0(I) -> $0 + I.
|
hex0(I) -> $0 + I.
|
||||||
|
|
||||||
|
|
||||||
|
sub_files(From) ->
|
||||||
|
{ok, SubFiles} = file:list_dir(From),
|
||||||
|
[filename:join(From, SubFile) || SubFile <- SubFiles].
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Test Functions
|
%%% Test Functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
@ -378,10 +383,11 @@ real_path_test() ->
|
||||||
find_test() ->
|
find_test() ->
|
||||||
%% Create a directory in /tmp for the test. Clean everything afterwards
|
%% Create a directory in /tmp for the test. Clean everything afterwards
|
||||||
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
{BaseDir, _SourceDir, {Name1, Name2, Name3, _NoName}} = setup_base_and_target(),
|
||||||
?assertMatch([Name2,
|
Result = find(BaseDir, "file[a-z]+\$"),
|
||||||
Name3,
|
?assertMatch(3, erlang:length(Result)),
|
||||||
Name1],
|
?assert(lists:member(Name1, Result)),
|
||||||
find(BaseDir, "file[a-z]+\$")),
|
?assert(lists:member(Name2, Result)),
|
||||||
|
?assert(lists:member(Name3, Result)),
|
||||||
remove(BaseDir, [recursive]).
|
remove(BaseDir, [recursive]).
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue