[MLton] Windows ports and paths
Stephen Weeks
MLton@mlton.org
Mon, 2 May 2005 14:44:15 -0700
> The obvious correct implementation is
>
> fun joinDirFile {dir, file} =
> let
> val {isAbs, vol, arcs} = fromString dir
> in
> toString {isAbs=isAbs, vol=vol, arcs=arcs@[file]}
> end
Both this suggestion and the previous one mean that
OS.Path.joinDirFile {dir = "b/", file = "c"}
evaluates to "b//c", unlike "b/c" which is what every SML
implementation says.
I think it makes more sense to remove a trailing empty arc using
concatArcs, just as concat does. So, I propose
fun joinDirFile {dir, file} =
if dir = "" andalso file = ""
then ""
else
let
val {arcs, isAbs, vol} = fromString dir
in
toString {arcs = concatArcs (arcs, [file]),
isAbs = isAbs,
vol = vol}
end
I needed the special case for both dir and file being empty because
otherwise toString raises Path.