MCPcopy Create free account
hub / github.com/kataras/iris / ReadDir

Method ReadDir

context/fs.go:62–96  ·  view source on GitHub ↗
(name string)

Source from the content-addressed store, hash-verified

60}
61
62func (f *httpFS) ReadDir(name string) ([]fs.DirEntry, error) {
63 name = filepath.ToSlash(name)
64 if name == "." {
65 name = "/"
66 }
67
68 file, err := f.fs.Open(name)
69 if err != nil {
70 return nil, err
71 }
72 defer file.Close()
73
74 infos, err := file.Readdir(-1)
75 if err != nil {
76 return nil, err
77 }
78
79 entries := make([]fs.DirEntry, 0, len(infos))
80 for _, info := range infos {
81 if info.IsDir() { // http file's does not return the whole tree, so read it.
82 sub, err := f.ReadDir(info.Name())
83 if err != nil {
84 return nil, err
85 }
86
87 entries = append(entries, sub...)
88 continue
89 }
90
91 entry := fs.FileInfoToDirEntry(info)
92 entries = append(entries, entry)
93 }
94
95 return entries, nil
96}
97
98// ResolveHTTPFS accepts a single input argument of any type
99// and tries to cast it to http.FileSystem.

Callers 1

fs.goFile · 0.80

Calls 5

CloseMethod · 0.65
NameMethod · 0.65
OpenMethod · 0.45
ReaddirMethod · 0.45
IsDirMethod · 0.45

Tested by

no test coverage detected