aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go47
1 files changed, 0 insertions, 47 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go b/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go
deleted file mode 100644
index acf3f56..0000000
--- a/vendor/github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system/chtimes.go
+++ /dev/null
@@ -1,47 +0,0 @@
1package system
2
3import (
4 "os"
5 "syscall"
6 "time"
7 "unsafe"
8)
9
10var (
11 maxTime time.Time
12)
13
14func init() {
15 if unsafe.Sizeof(syscall.Timespec{}.Nsec) == 8 {
16 // This is a 64 bit timespec
17 // os.Chtimes limits time to the following
18 maxTime = time.Unix(0, 1<<63-1)
19 } else {
20 // This is a 32 bit timespec
21 maxTime = time.Unix(1<<31-1, 0)
22 }
23}
24
25// Chtimes changes the access time and modified time of a file at the given path
26func Chtimes(name string, atime time.Time, mtime time.Time) error {
27 unixMinTime := time.Unix(0, 0)
28 unixMaxTime := maxTime
29
30 // If the modified time is prior to the Unix Epoch, or after the
31 // end of Unix Time, os.Chtimes has undefined behavior
32 // default to Unix Epoch in this case, just in case
33
34 if atime.Before(unixMinTime) || atime.After(unixMaxTime) {
35 atime = unixMinTime
36 }
37
38 if mtime.Before(unixMinTime) || mtime.After(unixMaxTime) {
39 mtime = unixMinTime
40 }
41
42 if err := os.Chtimes(name, atime, mtime); err != nil {
43 return err
44 }
45
46 return nil
47}