OS specific syscall.Stat_t use into separate file

The use of Stat_t in request-example.go is unix specific and broke the
Windows OS builds. This is the minimal change to fix that.

This fixes #157.
This commit is contained in:
John Eikenberry 2017-02-24 20:06:51 -08:00
parent 2eb63db49d
commit e1c86753b9
3 changed files with 20 additions and 2 deletions

View File

@ -11,7 +11,6 @@ import (
"os"
"path/filepath"
"sync"
"syscall"
"time"
)
@ -187,7 +186,7 @@ func (f *memFile) Mode() os.FileMode {
func (f *memFile) ModTime() time.Time { return f.modtime }
func (f *memFile) IsDir() bool { return f.isdir }
func (f *memFile) Sys() interface{} {
return &syscall.Stat_t{Uid: 65534, Gid: 65534}
return fakeFileInfoSys()
}
// Read/Write

9
request-stub.go Normal file
View File

@ -0,0 +1,9 @@
// +build !cgo,!plan9 windows android
package sftp
import "syscall"
func fakeFileInfoSys() interface{} {
return &syscall.Stat_t{Uid: 65534, Gid: 65534}
}

10
request-unix.go Normal file
View File

@ -0,0 +1,10 @@
// +build darwin dragonfly freebsd !android,linux netbsd openbsd solaris
// +build cgo
package sftp
import "syscall"
func fakeFileInfoSys() interface{} {
return &syscall.Stat_t{Uid: 65534, Gid: 65534}
}