mirror of
https://github.com/restic/restic.git
synced 2025-01-21 06:48:35 +00:00
52 lines
979 B
Go
52 lines
979 B
Go
package fs
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/restic/restic/internal/restic"
|
|
)
|
|
|
|
type metadataHandle interface {
|
|
Name() string
|
|
Stat() (*ExtendedFileInfo, error)
|
|
Readlink() (string, error)
|
|
Xattr(ignoreListError bool) ([]restic.ExtendedAttribute, error)
|
|
// windows only
|
|
SecurityDescriptor() (*[]byte, error)
|
|
}
|
|
|
|
type pathMetadataHandle struct {
|
|
name string
|
|
flag int
|
|
}
|
|
|
|
var _ metadataHandle = &pathMetadataHandle{}
|
|
|
|
func newPathMetadataHandle(name string, flag int) *pathMetadataHandle {
|
|
return &pathMetadataHandle{
|
|
name: fixpath(name),
|
|
flag: flag,
|
|
}
|
|
}
|
|
|
|
func (p *pathMetadataHandle) Name() string {
|
|
return p.name
|
|
}
|
|
|
|
func (p *pathMetadataHandle) Stat() (*ExtendedFileInfo, error) {
|
|
var fi os.FileInfo
|
|
var err error
|
|
if p.flag&O_NOFOLLOW != 0 {
|
|
fi, err = os.Lstat(p.name)
|
|
} else {
|
|
fi, err = os.Stat(p.name)
|
|
}
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return extendedStat(fi), nil
|
|
}
|
|
|
|
func (p *pathMetadataHandle) Readlink() (string, error) {
|
|
return os.Readlink(p.name)
|
|
}
|