MCPcopy Index your code
hub / github.com/labstack/echo / subFS

Function subFS

echo.go:896–911  ·  view source on GitHub ↗
(currentFs fs.FS, root string)

Source from the content-addressed store, hash-verified

894}
895
896func 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.

Callers 1

MustSubFSFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…