Given the conditions:
- Current working directory is not
/. (Say /tmp for example.)
- Get fs with:
fsys, _ := hackpadfs_os.NewFS().Sub("mydir") (Assume /tmp/mydir/ exists.)
- Call
fsys.Stat(".")
Stat fails with:
stat : no such file or directory
While debugging this, it is apparent that this is caused by fs.rootedPath assuming that the sub path is an absolute path, not a path relative to the cwd. I.e. given the example situation, it runs os.Stat("/mydir"), not os.Stat("/tmp/mydir") which is what I would expect.
The following go playground demonstrates: https://go.dev/play/p/hYuq0VNVybc
It seems Sub is not safe to use with paths relative to the cwd, and given that you can't use rooted paths (gofs.ValidPath disallows them), it is not usable in general.
Given the conditions:
/. (Say/tmpfor example.)fsys, _ := hackpadfs_os.NewFS().Sub("mydir")(Assume/tmp/mydir/exists.)fsys.Stat(".")Stat fails with:
While debugging this, it is apparent that this is caused by
fs.rootedPathassuming that the sub path is an absolute path, not a path relative to the cwd. I.e. given the example situation, it runsos.Stat("/mydir"), notos.Stat("/tmp/mydir")which is what I would expect.The following go playground demonstrates: https://go.dev/play/p/hYuq0VNVybc
It seems
Subis not safe to use with paths relative to the cwd, and given that you can't use rooted paths (gofs.ValidPathdisallows them), it is not usable in general.