2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-25 03:52:36 +00:00
restic/src/restic/node_xattr.go

39 lines
800 B
Go
Raw Normal View History

// +build !openbsd
// +build !windows
package restic
import (
"syscall"
"github.com/pkg/xattr"
)
// Getxattr retrieves extended attribute data associated with path.
func Getxattr(path, name string) ([]byte, error) {
b, e := xattr.Getxattr(path, name)
if e == syscall.ENOTSUP {
return nil, nil
}
return b, e
}
// Listxattr retrieves a list of names of extended attributes associated with the
// given path in the file system.
func Listxattr(path string) ([]string, error) {
s, e := xattr.Listxattr(path)
if e == syscall.ENOTSUP {
return nil, nil
}
return s, e
}
// Setxattr associates name and data together as an attribute of path.
func Setxattr(path, name string, data []byte) error {
e := xattr.Setxattr(path, name, data)
if e == syscall.ENOTSUP {
return nil
}
return e
}