diff --git a/paths.go b/paths.go index c42ca31..a9b8bc0 100644 --- a/paths.go +++ b/paths.go @@ -32,6 +32,7 @@ package paths import ( "fmt" "io" + "io/fs" "os" "path/filepath" "strings" @@ -69,10 +70,18 @@ func NewFromFile(file *os.File) *Path { // Stat returns a FileInfo describing the named file. The result is // cached internally for next queries. To ensure that the cached // FileInfo entry is updated just call Stat again. -func (p *Path) Stat() (os.FileInfo, error) { +func (p *Path) Stat() (fs.FileInfo, error) { return os.Stat(p.path) } +// Lstat returns a FileInfo describing the named file. If the file is +// a symbolic link, the returned FileInfo describes the symbolic link. +// Lstat makes no attempt to follow the link. If there is an error, it +// will be of type *PathError. +func (p *Path) Lstat() (fs.FileInfo, error) { + return os.Lstat(p.path) +} + // Clone create a copy of the Path object func (p *Path) Clone() *Path { return New(p.path)