Erlang/OTP Forums

Author Message

<  Erlang bugs mailing list  ~  filename:join breaks Windows UNC paths

Guest
Posted: Sun Jul 18, 2010 6:58 am Reply with quote
Guest
Hello,

"Normalize" feature of filename:join breaks Windows UNC paths:
filename:join("//host/share", "file") returns "/host/share/file" on Windows instead "//host/share/file".

Patch below fixes the problem.

Regards,
Evgeny.

------------------- 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
@@ -316,6 +316,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 --------------------------------

________________________________________________________________
erlang-bugs (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-bugs-unsubscribe@erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum