The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #743 from talex5/win-fwd-slash

Eio.Path: always use "/" as separator

authored by

Thomas Leonard and committed by
GitHub
4d77de9c ae933626

+40 -3
+14 -3
vendor/opam/eio/lib_eio/path.ml
··· 1 1 type 'a t = 'a Fs.dir * Fs.path 2 2 3 + (* Like [Filename.is_relative] but always using "/" as the separator. *) 4 + let is_relative = function 5 + | "" -> true 6 + | x -> x.[0] <> '/' 7 + 8 + (* Like [Filename.concat] but always using "/" as the separator. *) 9 + let concat a b = 10 + let l = String.length a in 11 + if l = 0 || a.[l - 1] = '/' then a ^ b 12 + else a ^ "/" ^ b 13 + 3 14 let ( / ) (dir, p1) p2 = 4 15 match p1, p2 with 5 - | p1, "" -> (dir, Filename.concat p1 p2) 6 - | _, p2 when not (Filename.is_relative p2) -> (dir, p2) 16 + | p1, "" -> (dir, concat p1 p2) 17 + | _, p2 when not (is_relative p2) -> (dir, p2) 7 18 | ".", p2 -> (dir, p2) 8 - | p1, p2 -> (dir, Filename.concat p1 p2) 19 + | p1, p2 -> (dir, concat p1 p2) 9 20 10 21 let pp f (Resource.T (t, ops), p) = 11 22 let module X = (val (Resource.get ops Fs.Pi.Dir)) in
+26
vendor/opam/eio/tests/fs.md
··· 985 985 +seek from end: 9 986 986 - : unit = () 987 987 ``` 988 + 989 + # Extending paths 990 + 991 + ```ocaml 992 + # run @@ fun env -> 993 + let base = fst env#cwd in 994 + List.iter (fun (a, b) -> traceln "%S / %S = %S" a b (snd ((base, a) / b))) [ 995 + "foo", "bar"; 996 + "foo/", "bar"; 997 + "foo", "/bar"; 998 + "foo", ""; 999 + "foo/", ""; 1000 + "", ""; 1001 + "", "bar"; 1002 + "/", ""; 1003 + ] 1004 + +"foo" / "bar" = "foo/bar" 1005 + +"foo/" / "bar" = "foo/bar" 1006 + +"foo" / "/bar" = "/bar" 1007 + +"foo" / "" = "foo/" 1008 + +"foo/" / "" = "foo/" 1009 + +"" / "" = "" 1010 + +"" / "bar" = "bar" 1011 + +"/" / "" = "/" 1012 + - : unit = () 1013 + ```