-
Notifications
You must be signed in to change notification settings - Fork 2
/
xattr.go
45 lines (38 loc) · 997 Bytes
/
xattr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// xattr.go - extended attribute support for go-walk
//
// (c) 2023- Sudhi Herle <sudhi@herle.net>
//
// Licensing Terms: GPLv2
//
// If you need a commercial license for this work, please contact
// the author.
//
// This software does not come with any express or implied
// warranty; it is provided "as is". No claim is made to its
// suitability for any purpose.
package walk
import (
"fmt"
"strings"
)
type Xattr map[string]string
func (x Xattr) String() string {
var s strings.Builder
for k, v := range x {
s.WriteString(fmt.Sprintf("%s=%s\n", k, v))
}
return s.String()
}
// NewXattr returns the extended attributes of file 'fn'
func GetXattr(fn string) (Xattr, error) {
return getxattr(fn)
}
// SetXattr sets the extended attributes of file 'fn' with
// the data in 'x'
func SetXattr(fn string, x Xattr) error {
return setxattr(fn, x)
}
// DelXattr deletes the extended attributes in 'x' from file 'fn'
func DelXattr(fn string, x Xattr) error {
return delxattr(fn, x)
}