[erlang-bugs] filename:join breaks Windows UNC paths

wohali joant@REDACTED
Tue Jul 19 19:27:33 CEST 2011


Sorry to resurrect an old post, but this just bit me and cost me a day or
two. Evgeny's patch works and applies to R14B01 and R14B03, though the line
numbers are now a bit off. I've edited the patch below. 

Not sure what the proper convention is, but I'd like to vote for this being
included in a future release if possible. The current assumption that all
paths on win32 start with a drive letter is no longer valid, especially if
extended-path name notation is being used (\\?\very\long\path). This is an
increasingly common need.

------------------- patch --------------------------------
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl
index 01c06e4..8da54ef 100644
--- a/lib/stdlib/src/filename.erl
+++ b/lib/stdlib/src/filename.erl
@@ -426,6 +426,10 @@ join(Name1, Name2) when is_atom(Name2) ->
 %% It is the responsibility of the caller to ensure that RelativeName
 %% is relative.

+join1([$/, $/ | Rest], RelativeName, [], win32) -> [$/, $/ | join1(Rest,
RelativeName, [], win32)];
+join1([$/, $\\ | Rest], RelativeName, [], win32) -> [$/, $/ | join1(Rest,
RelativeName, [], win32)];
+join1([$\\, $/ | Rest], RelativeName, [], win32) -> [$/, $/ | join1(Rest,
RelativeName, [], win32)];
+join1([$\\, $\\ | Rest], RelativeName, [], win32) -> [$/, $/ | join1(Rest,
RelativeName, [], win32)];
 join1([UcLetter, $:|Rest], RelativeName, [], win32)
 when is_integer(UcLetter), UcLetter >= $A, UcLetter =< $Z ->
     join1(Rest, RelativeName, [$:, UcLetter+$a-$A], win32);
------------------- patch --------------------------------


--
View this message in context: http://erlang.2086793.n4.nabble.com/filename-join-breaks-Windows-UNC-paths-tp2292894p3678716.html
Sent from the Erlang Bugs mailing list archive at Nabble.com.



More information about the erlang-bugs mailing list