Skip to content

Commit

Permalink
Merge pull request moby#6493 from vieux/fix_cp_mac_os
Browse files Browse the repository at this point in the history
allow utimes on mac os, only lutimes isn't supported
  • Loading branch information
Michael Crosby committed Jun 19, 2014
2 parents 4ad5af8 + b132e7b commit abda245
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions archive/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
ts := []syscall.Timespec{timeToTimespec(hdr.AccessTime), timeToTimespec(hdr.ModTime)}
// syscall.UtimesNano doesn't support a NOFOLLOW flag atm, and
if hdr.Typeflag != tar.TypeSymlink {
if err := system.UtimesNano(path, ts); err != nil {
if err := system.UtimesNano(path, ts); err != nil && err != system.ErrNotSupportedPlatform {
return err
}
} else {
if err := system.LUtimesNano(path, ts); err != nil {
if err := system.LUtimesNano(path, ts); err != nil && err != system.ErrNotSupportedPlatform {
return err
}
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/system/utimes_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package system

import "syscall"

func LUtimesNano(path string, ts []syscall.Timespec) error {
return ErrNotSupportedPlatform
}

func UtimesNano(path string, ts []syscall.Timespec) error {
return syscall.UtimesNano(path, ts)
}
5 changes: 1 addition & 4 deletions pkg/system/utimes_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,5 @@ func LUtimesNano(path string, ts []syscall.Timespec) error {
}

func UtimesNano(path string, ts []syscall.Timespec) error {
if err := syscall.UtimesNano(path, ts); err != nil {
return err
}
return nil
return syscall.UtimesNano(path, ts)
}
2 changes: 1 addition & 1 deletion pkg/system/utimes_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !linux,!freebsd
// +build !linux,!freebsd,!darwin

package system

Expand Down

0 comments on commit abda245

Please sign in to comment.