mirror of
https://github.com/golang/go
synced 2024-11-25 03:27:58 -07:00
exp/winfsnotify: fix build.
R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/5483057
This commit is contained in:
parent
599c18fa3f
commit
1c50c32af0
@ -75,7 +75,7 @@ type Watcher struct {
|
|||||||
// NewWatcher creates and returns a Watcher.
|
// NewWatcher creates and returns a Watcher.
|
||||||
func NewWatcher() (*Watcher, error) {
|
func NewWatcher() (*Watcher, error) {
|
||||||
port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0)
|
port, e := syscall.CreateIoCompletionPort(syscall.InvalidHandle, 0, 0, 0)
|
||||||
if e != 0 {
|
if e != nil {
|
||||||
return nil, os.NewSyscallError("CreateIoCompletionPort", e)
|
return nil, os.NewSyscallError("CreateIoCompletionPort", e)
|
||||||
}
|
}
|
||||||
w := &Watcher{
|
w := &Watcher{
|
||||||
@ -147,7 +147,7 @@ func (w *Watcher) RemoveWatch(path string) error {
|
|||||||
|
|
||||||
func (w *Watcher) wakeupReader() error {
|
func (w *Watcher) wakeupReader() error {
|
||||||
e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil)
|
e := syscall.PostQueuedCompletionStatus(w.port, 0, 0, nil)
|
||||||
if e != 0 {
|
if e != nil {
|
||||||
return os.NewSyscallError("PostQueuedCompletionStatus", e)
|
return os.NewSyscallError("PostQueuedCompletionStatus", e)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -155,7 +155,7 @@ func (w *Watcher) wakeupReader() error {
|
|||||||
|
|
||||||
func getDir(pathname string) (dir string, err error) {
|
func getDir(pathname string) (dir string, err error) {
|
||||||
attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname))
|
attr, e := syscall.GetFileAttributes(syscall.StringToUTF16Ptr(pathname))
|
||||||
if e != 0 {
|
if e != nil {
|
||||||
return "", os.NewSyscallError("GetFileAttributes", e)
|
return "", os.NewSyscallError("GetFileAttributes", e)
|
||||||
}
|
}
|
||||||
if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
|
if attr&syscall.FILE_ATTRIBUTE_DIRECTORY != 0 {
|
||||||
@ -173,11 +173,11 @@ func getIno(path string) (ino *inode, err error) {
|
|||||||
syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
|
syscall.FILE_SHARE_READ|syscall.FILE_SHARE_WRITE|syscall.FILE_SHARE_DELETE,
|
||||||
nil, syscall.OPEN_EXISTING,
|
nil, syscall.OPEN_EXISTING,
|
||||||
syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0)
|
syscall.FILE_FLAG_BACKUP_SEMANTICS|syscall.FILE_FLAG_OVERLAPPED, 0)
|
||||||
if e != 0 {
|
if e != nil {
|
||||||
return nil, os.NewSyscallError("CreateFile", e)
|
return nil, os.NewSyscallError("CreateFile", e)
|
||||||
}
|
}
|
||||||
var fi syscall.ByHandleFileInformation
|
var fi syscall.ByHandleFileInformation
|
||||||
if e = syscall.GetFileInformationByHandle(h, &fi); e != 0 {
|
if e = syscall.GetFileInformationByHandle(h, &fi); e != nil {
|
||||||
syscall.CloseHandle(h)
|
syscall.CloseHandle(h)
|
||||||
return nil, os.NewSyscallError("GetFileInformationByHandle", e)
|
return nil, os.NewSyscallError("GetFileInformationByHandle", e)
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ func (w *Watcher) addWatch(pathname string, flags uint64) error {
|
|||||||
}
|
}
|
||||||
watchEntry := w.watches.get(ino)
|
watchEntry := w.watches.get(ino)
|
||||||
if watchEntry == nil {
|
if watchEntry == nil {
|
||||||
if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != 0 {
|
if _, e := syscall.CreateIoCompletionPort(ino.handle, w.port, 0, 0); e != nil {
|
||||||
syscall.CloseHandle(ino.handle)
|
syscall.CloseHandle(ino.handle)
|
||||||
return os.NewSyscallError("CreateIoCompletionPort", e)
|
return os.NewSyscallError("CreateIoCompletionPort", e)
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ func (w *Watcher) deleteWatch(watch *watch) {
|
|||||||
|
|
||||||
// Must run within the I/O thread.
|
// Must run within the I/O thread.
|
||||||
func (w *Watcher) startRead(watch *watch) error {
|
func (w *Watcher) startRead(watch *watch) error {
|
||||||
if e := syscall.CancelIo(watch.ino.handle); e != 0 {
|
if e := syscall.CancelIo(watch.ino.handle); e != nil {
|
||||||
w.Error <- os.NewSyscallError("CancelIo", e)
|
w.Error <- os.NewSyscallError("CancelIo", e)
|
||||||
w.deleteWatch(watch)
|
w.deleteWatch(watch)
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ func (w *Watcher) startRead(watch *watch) error {
|
|||||||
mask |= toWindowsFlags(m)
|
mask |= toWindowsFlags(m)
|
||||||
}
|
}
|
||||||
if mask == 0 {
|
if mask == 0 {
|
||||||
if e := syscall.CloseHandle(watch.ino.handle); e != 0 {
|
if e := syscall.CloseHandle(watch.ino.handle); e != nil {
|
||||||
w.Error <- os.NewSyscallError("CloseHandle", e)
|
w.Error <- os.NewSyscallError("CloseHandle", e)
|
||||||
}
|
}
|
||||||
delete(w.watches[watch.ino.volume], watch.ino.index)
|
delete(w.watches[watch.ino.volume], watch.ino.index)
|
||||||
@ -312,7 +312,7 @@ func (w *Watcher) startRead(watch *watch) error {
|
|||||||
}
|
}
|
||||||
e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0],
|
e := syscall.ReadDirectoryChanges(watch.ino.handle, &watch.buf[0],
|
||||||
uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0)
|
uint32(unsafe.Sizeof(watch.buf)), false, mask, nil, &watch.ov, 0)
|
||||||
if e != 0 {
|
if e != nil {
|
||||||
err := os.NewSyscallError("ReadDirectoryChanges", e)
|
err := os.NewSyscallError("ReadDirectoryChanges", e)
|
||||||
if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
|
if e == syscall.ERROR_ACCESS_DENIED && watch.mask&provisional == 0 {
|
||||||
// Watched directory was probably removed
|
// Watched directory was probably removed
|
||||||
@ -354,7 +354,7 @@ func (w *Watcher) readEvents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
if e := syscall.CloseHandle(w.port); e != 0 {
|
if e := syscall.CloseHandle(w.port); e != nil {
|
||||||
err = os.NewSyscallError("CloseHandle", e)
|
err = os.NewSyscallError("CloseHandle", e)
|
||||||
}
|
}
|
||||||
close(w.Event)
|
close(w.Event)
|
||||||
@ -386,7 +386,7 @@ func (w *Watcher) readEvents() {
|
|||||||
default:
|
default:
|
||||||
w.Error <- os.NewSyscallError("GetQueuedCompletionPort", e)
|
w.Error <- os.NewSyscallError("GetQueuedCompletionPort", e)
|
||||||
continue
|
continue
|
||||||
case 0:
|
case nil:
|
||||||
}
|
}
|
||||||
|
|
||||||
var offset uint32
|
var offset uint32
|
||||||
|
Loading…
Reference in New Issue
Block a user