MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / ListStaticFiles

Function ListStaticFiles

tsunami/app/defaultclient.go:248–276  ·  view source on GitHub ↗

ListStaticFiles returns FileInfo for all files in the embedded static filesystem. The Name() of each FileInfo will be the full path prefixed with "static/" (e.g., "static/config.json"), which can be passed directly to ReadStaticFile or OpenStaticFile.

()

Source from the content-addressed store, hash-verified

246// The Name() of each FileInfo will be the full path prefixed with "static/" (e.g., "static/config.json"),
247// which can be passed directly to ReadStaticFile or OpenStaticFile.
248func ListStaticFiles() ([]fs.FileInfo, error) {
249 client := engine.GetDefaultClient()
250 if client.StaticFS == nil {
251 return nil, errors.New("static files not available before app initialization; use AppInit to access files during initialization")
252 }
253
254 var fileInfos []fs.FileInfo
255 err := fs.WalkDir(client.StaticFS, ".", func(path string, d fs.DirEntry, err error) error {
256 if err != nil {
257 return err
258 }
259 if !d.IsDir() {
260 info, err := d.Info()
261 if err != nil {
262 return err
263 }
264 fullPath := "static/" + path
265 fileInfos = append(fileInfos, &staticFileInfo{
266 fullPath: fullPath,
267 info: info,
268 })
269 }
270 return nil
271 })
272 if err != nil {
273 return nil, err
274 }
275 return fileInfos, nil
276}

Callers

nothing calls this directly

Calls 3

GetDefaultClientFunction · 0.92
InfoMethod · 0.80
IsDirMethod · 0.45

Tested by

no test coverage detected