From 9708887c78138cfc2697e397eb4127d2ed1f61e7 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 16 Sep 2014 12:18:04 +0200 Subject: Fix handling of single dot in filename:join/2 The reference manual says that filename:join(A,B) is equivalent to filename:join([A,B]). In some rare cases this turns out not to be true: 1> filename:join("/a/.","b"). "/a/./b" 2> filename:join(["/a/.","b"]). "/a/b" In general, filename:join/1,2 removes single dots from the resulting path, except dots that occur at the beginning or end of the path. The problem above occurs when the first argument to join/2 ends with a dot, then it is not removed even if the second argument differs from an empty string and thus the dot ends up in "the middle" of the path. This commit corrects this problem. A single dot is now only kept if it occurs at the very beginning or the very end of the resulting path. Test of filename:join/1,2 are added in filename_SUITE. In addition, filelib_SUITE is updated with more tests of filelib:wildcard/2 since this failed when the given current directory (second argument) ended with a dot. --- lib/stdlib/test/filelib_SUITE.erl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/stdlib/test/filelib_SUITE.erl') diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl index 040ae1effc..3fd96142d9 100644 --- a/lib/stdlib/test/filelib_SUITE.erl +++ b/lib/stdlib/test/filelib_SUITE.erl @@ -77,7 +77,8 @@ wildcard_one(Config) when is_list(Config) -> L = filelib:wildcard(Wc), L = filelib:wildcard(Wc, erl_prim_loader), L = filelib:wildcard(Wc, "."), - L = filelib:wildcard(Wc, Dir) + L = filelib:wildcard(Wc, Dir), + L = filelib:wildcard(Wc, Dir++"/.") end), ?line file:set_cwd(OldCwd), ?line ok = file:del_dir(Dir), -- cgit v1.2.3