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

Dave Cottlehuber <>
Sun Aug 14 05:02:04 CEST 2011


On 20 July 2011 05:27, wohali <> wrote:
> 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.
> _______________________________________________
> erlang-bugs mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-bugs
>

Improve win32 UNC path support in stdlib/filename.erl
Thanks Wohali & Evgeny.
NB cross-posted to erlang-bugs & erlang-patches.

https://github.com/dch/otp/compare/win32-unc-path-support

git fetch git://github.com/dch/otp.git win32-unc-path-support

Cheers,
Dave


More information about the erlang-patches mailing list