diff options
author | Siri Hansen <[email protected]> | 2014-09-16 12:18:04 +0200 |
---|---|---|
committer | Siri Hansen <[email protected]> | 2014-09-25 12:29:40 +0200 |
commit | 9708887c78138cfc2697e397eb4127d2ed1f61e7 (patch) | |
tree | 532068dcaa4d69acc773f9ad3897dd593832d153 /lib/stdlib/test/filelib_SUITE.erl | |
parent | 08fb3803a26d57c27cf9f0ef23c2fa49d15d0d33 (diff) | |
download | otp-9708887c78138cfc2697e397eb4127d2ed1f61e7.tar.gz otp-9708887c78138cfc2697e397eb4127d2ed1f61e7.tar.bz2 otp-9708887c78138cfc2697e397eb4127d2ed1f61e7.zip |
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.
Diffstat (limited to 'lib/stdlib/test/filelib_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/filelib_SUITE.erl | 3 |
1 files changed, 2 insertions, 1 deletions
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), |