From a476a844554d25fd704888f63a302659aa5dc67a Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 11 Jul 2014 14:04:49 +0200 Subject: Fix filelib:wildcard/2 when 'Cwd' ends with a dot In such case, filelib:wildcard/2 returned truncated results: 1> file:set_cwd("/usr/lib/erlang/lib"). ok 2> filelib:wildcard("stdlib-*/ebin/*.app", filename:absname(".")). ["dlib-2.1/ebin/stdlib.app"] --- lib/stdlib/src/filelib.erl | 2 +- lib/stdlib/test/filelib_SUITE.erl | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/filelib.erl b/lib/stdlib/src/filelib.erl index c0921e4cf1..b1dabf614a 100644 --- a/lib/stdlib/src/filelib.erl +++ b/lib/stdlib/src/filelib.erl @@ -371,7 +371,7 @@ compile_wildcard(Pattern, Cwd0) -> [Root|Rest] = filename:split(Pattern), case filename:pathtype(Root) of relative -> - Cwd = filename:join([Cwd0]), + Cwd = prepare_base(Cwd0), compile_wildcard_2([Root|Rest], {cwd,Cwd}); _ -> compile_wildcard_2(Rest, {root,0,Root}) diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl index 8203a03a7a..1135828fae 100644 --- a/lib/stdlib/test/filelib_SUITE.erl +++ b/lib/stdlib/test/filelib_SUITE.erl @@ -86,6 +86,7 @@ wildcard_two(Config) when is_list(Config) -> ?line ok = file:make_dir(Dir), ?line do_wildcard_1(Dir, fun(Wc) -> io:format("~p~n",[{Wc,Dir, X = filelib:wildcard(Wc, Dir)}]),X end), ?line do_wildcard_1(Dir, fun(Wc) -> filelib:wildcard(Wc, Dir++"/") end), + ?line do_wildcard_1(Dir, fun(Wc) -> filelib:wildcard(Wc, Dir++"/.") end), case os:type() of {win32,_} -> ok; -- cgit v1.2.3