mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
e96d1c3754
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
32 lines
510 B
Go
32 lines
510 B
Go
// +build !windows
|
|
|
|
package fs
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/pkg/errors"
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func fixRootDirectory(p string) string {
|
|
return p
|
|
}
|
|
|
|
func Utimes(p string, tm *time.Time) error {
|
|
if tm == nil {
|
|
return nil
|
|
}
|
|
|
|
ts, err := unix.TimeToTimespec(*tm)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
timespec := []unix.Timespec{ts, ts}
|
|
if err := unix.UtimesNanoAt(unix.AT_FDCWD, p, timespec, unix.AT_SYMLINK_NOFOLLOW); err != nil {
|
|
return errors.Wrapf(err, "failed to utime %s", p)
|
|
}
|
|
|
|
return nil
|
|
}
|