(currentFs fs.FS, root string)
| 894 | } |
| 895 | |
| 896 | func subFS(currentFs fs.FS, root string) (fs.FS, error) { |
| 897 | root = filepath.ToSlash(filepath.Clean(root)) // note: fs.FS operates only with slashes. `ToSlash` is necessary for Windows |
| 898 | if dFS, ok := currentFs.(*defaultFS); ok { |
| 899 | // we need to make exception for `defaultFS` instances as it interprets root prefix differently from fs.FS. |
| 900 | // fs.Fs.Open does not like relative paths ("./", "../") and absolute paths at all but prior echo.Filesystem we |
| 901 | // were able to use paths like `./myfile.log`, `/etc/hosts` and these would work fine with `os.Open` but not with fs.Fs |
| 902 | if !filepath.IsAbs(root) { |
| 903 | root = filepath.Join(dFS.prefix, root) |
| 904 | } |
| 905 | return &defaultFS{ |
| 906 | prefix: root, |
| 907 | fs: os.DirFS(root), |
| 908 | }, nil |
| 909 | } |
| 910 | return fs.Sub(currentFs, root) |
| 911 | } |
| 912 | |
| 913 | // MustSubFS creates sub FS from current filesystem or panic on failure. |
| 914 | // Panic happens when `fsRoot` contains invalid path according to `fs.ValidPath` rules. |
no outgoing calls
no test coverage detected
searching dependent graphs…