summaryrefslogtreecommitdiff
path: root/vendor/github.com/moby/go-archive/time_windows.go
blob: af1f7c8f3a075962374f476edd4e17513ed2ba94 (plain)
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
package archive

import (
	"os"
	"time"

	"golang.org/x/sys/windows"
)

func chtimes(name string, atime time.Time, mtime time.Time) error {
	if err := os.Chtimes(name, atime, mtime); err != nil {
		return err
	}

	pathp, err := windows.UTF16PtrFromString(name)
	if err != nil {
		return err
	}
	h, err := windows.CreateFile(pathp,
		windows.FILE_WRITE_ATTRIBUTES, windows.FILE_SHARE_WRITE, nil,
		windows.OPEN_EXISTING, windows.FILE_FLAG_BACKUP_SEMANTICS, 0)
	if err != nil {
		return err
	}
	defer windows.Close(h)
	c := windows.NsecToFiletime(mtime.UnixNano())
	return windows.SetFileTime(h, &c, nil, nil)
}

func lchtimes(name string, atime time.Time, mtime time.Time) error {
	return nil
}