(ctx context.Context, fileSystem fs.FS, dir fs.ReadDirFile, root, urlPath string, repl *caddy.Replacer)
| 214 | } |
| 215 | |
| 216 | func (fsrv *FileServer) loadDirectoryContents(ctx context.Context, fileSystem fs.FS, dir fs.ReadDirFile, root, urlPath string, repl *caddy.Replacer) (*browseTemplateContext, error) { |
| 217 | // modTime for the directory itself |
| 218 | stat, err := dir.Stat() |
| 219 | if err != nil { |
| 220 | return nil, err |
| 221 | } |
| 222 | dirLimit := defaultDirEntryLimit |
| 223 | if fsrv.Browse.FileLimit != 0 { |
| 224 | dirLimit = fsrv.Browse.FileLimit |
| 225 | } |
| 226 | files, err := dir.ReadDir(dirLimit) |
| 227 | if err != nil && err != io.EOF { |
| 228 | return nil, err |
| 229 | } |
| 230 | |
| 231 | // user can presumably browse "up" to parent folder if path is longer than "/" |
| 232 | canGoUp := len(urlPath) > 1 |
| 233 | |
| 234 | return fsrv.directoryListing(ctx, fileSystem, stat.ModTime(), files, canGoUp, root, urlPath, repl), nil |
| 235 | } |
| 236 | |
| 237 | // browseApplyQueryParams applies query parameters to the listing. |
| 238 | // It mutates the listing and may set cookies. |
no test coverage detected