Add Windows node support.

The syscall.Stat_t doesn't exist on Windows, so it is replaced by an interface,
which Windows can fill out, and field access is replaced by function calls.

Common Unix functionality is put into "node_unix.go", so there is less boilerplate.

Symlinks are skipped on Windows, since they require admin privileges.
This commit is contained in:
Klaus Post 2015-08-14 15:57:47 +02:00
parent 2e7b40baca
commit dfe232cf46
8 changed files with 189 additions and 64 deletions

View file

@ -3,7 +3,6 @@ package restic
import (
"os"
"syscall"
"time"
)
func (node *Node) OpenForReading() (*os.File, error) {
@ -14,15 +13,10 @@ func (node *Node) OpenForReading() (*os.File, error) {
return file, err
}
func (node *Node) fillTimes(stat *syscall.Stat_t) {
node.ChangeTime = time.Unix(stat.Ctim.Unix())
node.AccessTime = time.Unix(stat.Atim.Unix())
}
func changeTime(stat *syscall.Stat_t) time.Time {
return time.Unix(stat.Ctim.Unix())
}
func (node Node) restoreSymlinkTimestamps(path string, utimes [2]syscall.Timespec) error {
return nil
}
func (s statUnix) atim() syscall.Timespec { return s.Atim }
func (s statUnix) mtim() syscall.Timespec { return s.Mtim }
func (s statUnix) ctim() syscall.Timespec { return s.Ctim }