mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-28 22:19:59 +02:00
Add fileStat to tpl/os/os
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
a6b1eb1e91
commit
d71120852a
19
tpl/os/os.go
19
tpl/os/os.go
@@ -130,3 +130,22 @@ func (ns *Namespace) FileExists(i interface{}) (bool, error) {
|
||||
|
||||
return status, nil
|
||||
}
|
||||
|
||||
// FileStat Stat returns the os.FileInfo structure describing file.
|
||||
func (ns *Namespace) FileStat(i interface{}) (_os.FileInfo, error) {
|
||||
path, err := cast.ToStringE(i)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if path == "" {
|
||||
return nil, errors.New("fileStat needs a path to a file")
|
||||
}
|
||||
|
||||
r, err := ns.readFileFs.Stat(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user