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.
()
| 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. |
| 248 | func 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 | } |
nothing calls this directly
no test coverage detected