Closed hcarty closed 8 years ago
I think this is related (example from utop, but confirmed in compiled code):
# OS.Path.fold ~dotfiles:true ~elements:`Files ~traverse:`Any (fun _ _ -> ()) () [Fpath.v "/"];;
Exception: Invalid_argument "\"./\": invalid segment".
I think the issue is coming from https://github.com/dbuenzli/bos/blob/master/src/bos_os_path.ml#L446, specifically the call to Fpath.base
.
# Fpath.base @@ Fpath.v "/"
- : Fpath.t = ./
If I'm reading the OS.Path.fold
code correctly (and it's been a long weekend so I may not be...), the ./
result from Fpath.base
causes fold
to skip everything under /
if dotfiles
is false
. If dotfiles
is true
the code ends up interpreting ./
as an invalid path segment as seen in the Invalid_argument
result above.
Thanks for the analysis. It seems the line you mention is broken beyond that, it should be using split_base
. The current implementation trips over filepaths whose last segment is ..
. I'm looking into it.
Thanks!
42a11f6 should solve most of the problems. There's still one quirk though see #64.
This code:
returns
Ok ()
without walking the filesystem. If I use a valid path other than/
(orc:\
under Windows) thenfold
will recurse through directories as expected.