mirror of
https://github.com/genuinetools/reg.git
synced 2024-10-03 22:01:45 -04:00
ab6c553e6b
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
29 lines
766 B
Go
29 lines
766 B
Go
// +build !windows
|
|
|
|
package fstest
|
|
|
|
import (
|
|
"path/filepath"
|
|
"time"
|
|
|
|
"github.com/containerd/continuity/sysx"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// SetXAttr sets the xatter for the file
|
|
func SetXAttr(name, key, value string) Applier {
|
|
return applyFn(func(root string) error {
|
|
return sysx.LSetxattr(name, key, []byte(value), 0)
|
|
})
|
|
}
|
|
|
|
// Lchtimes changes access and mod time of file without following symlink
|
|
func Lchtimes(name string, atime, mtime time.Time) Applier {
|
|
return applyFn(func(root string) error {
|
|
path := filepath.Join(root, name)
|
|
at := unix.NsecToTimespec(atime.UnixNano())
|
|
mt := unix.NsecToTimespec(mtime.UnixNano())
|
|
utimes := [2]unix.Timespec{at, mt}
|
|
return unix.UtimesNanoAt(unix.AT_FDCWD, path, utimes[0:], unix.AT_SYMLINK_NOFOLLOW)
|
|
})
|
|
}
|