funcFileExists returns true if filename can be opened successfully.
(filename string)
| 424 | |
| 425 | // funcFileExists returns true if filename can be opened successfully. |
| 426 | func (c TemplateContext) funcFileExists(filename string) (bool, error) { |
| 427 | if c.Root == nil { |
| 428 | return false, fmt.Errorf("root file system not specified") |
| 429 | } |
| 430 | file, err := c.Root.Open(filename) |
| 431 | if err == nil { |
| 432 | file.Close() |
| 433 | return true, nil |
| 434 | } |
| 435 | return false, nil |
| 436 | } |
| 437 | |
| 438 | // funcFileStat returns Stat of a filename |
| 439 | func (c TemplateContext) funcFileStat(filename string) (fs.FileInfo, error) { |