MCPcopy
hub / github.com/labstack/echo / Open

Method Open

echo.go:880–894  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

878}
879
880func (fs defaultFS) Open(name string) (fs.File, error) {
881 // fs.FS.Open() already assumes that file names are relative to FS root path and considers name with prefix `/` as invalid
882 // For example `f.Name()` returns file names as absolute paths (e.g. `/tmp/data.csv`) so in case user wants to open
883 // a file with an absolute path we need to remove prefix and then call fs.FS.Open().
884 // not to force users to cut prefix from file name we do it here.
885 if filepath.IsAbs(name) {
886 if strings.HasPrefix(name, fs.prefix) {
887 name = name[len(fs.prefix):]
888 if len(name) > 1 && os.IsPathSeparator(name[0]) {
889 name = name[1:]
890 }
891 }
892 }
893 return fs.fs.Open(name)
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

Callers 4

TestNewDefaultFSFunction · 0.80
fsFileFunction · 0.80
ToMiddlewareMethod · 0.80

Calls

no outgoing calls

Tested by 2

TestNewDefaultFSFunction · 0.64