MCPcopy
hub / github.com/caddyserver/caddy / funcFileStat

Method funcFileStat

modules/caddyhttp/templates/tplcontext.go:439–451  ·  view source on GitHub ↗

funcFileStat returns Stat of a filename

(filename string)

Source from the content-addressed store, hash-verified

437
438// funcFileStat returns Stat of a filename
439func (c TemplateContext) funcFileStat(filename string) (fs.FileInfo, error) {
440 if c.Root == nil {
441 return nil, fmt.Errorf("root file system not specified")
442 }
443
444 file, err := c.Root.Open(path.Clean(filename))
445 if err != nil {
446 return nil, err
447 }
448 defer file.Close()
449
450 return file.Stat()
451}
452
453// funcHTTPError returns a structured HTTP handler error. EXPERIMENTAL; SUBJECT TO CHANGE.
454// Example usage: `{{if not (fileExists $includeFile)}}{{httpError 404}}{{end}}`

Callers

nothing calls this directly

Calls 3

OpenMethod · 0.80
StatMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected