forked from TrueCloudLab/restic
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:
parent
2e7b40baca
commit
dfe232cf46
8 changed files with 189 additions and 64 deletions
34
node_unix.go
Normal file
34
node_unix.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
|
||||
// +build dragonfly linux netbsd openbsd freebsd solaris darwin
|
||||
|
||||
package restic
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var mknod = syscall.Mknod
|
||||
var lchown = os.Lchown
|
||||
|
||||
type statUnix syscall.Stat_t
|
||||
|
||||
func toStatT(i interface{}) (statT, bool) {
|
||||
if i == nil {
|
||||
return nil, false
|
||||
}
|
||||
s, ok := i.(*syscall.Stat_t)
|
||||
if ok && s != nil {
|
||||
return statUnix(*s), true
|
||||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func (s statUnix) dev() uint64 { return uint64(s.Dev) }
|
||||
func (s statUnix) ino() uint64 { return uint64(s.Ino) }
|
||||
func (s statUnix) nlink() uint64 { return uint64(s.Nlink) }
|
||||
func (s statUnix) uid() uint32 { return uint32(s.Uid) }
|
||||
func (s statUnix) gid() uint32 { return uint32(s.Gid) }
|
||||
func (s statUnix) rdev() uint64 { return uint64(s.Rdev) }
|
||||
func (s statUnix) size() int64 { return int64(s.Size) }
|
Loading…
Add table
Add a link
Reference in a new issue