OLD | NEW |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Windows system calls. | 5 // Windows system calls. |
6 | 6 |
7 package syscall | 7 package syscall |
8 | 8 |
9 import ( | 9 import ( |
10 "unicode/utf16" | 10 "unicode/utf16" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) | 444 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) |
445 if e != nil { | 445 if e != nil { |
446 return e | 446 return e |
447 } | 447 } |
448 defer Close(h) | 448 defer Close(h) |
449 a := NsecToFiletime(tv[0].Nanoseconds()) | 449 a := NsecToFiletime(tv[0].Nanoseconds()) |
450 w := NsecToFiletime(tv[1].Nanoseconds()) | 450 w := NsecToFiletime(tv[1].Nanoseconds()) |
451 return SetFileTime(h, nil, &a, &w) | 451 return SetFileTime(h, nil, &a, &w) |
452 } | 452 } |
453 | 453 |
| 454 func UtimesNano(path string, ts []Timespec) (err error) { |
| 455 if len(ts) != 2 { |
| 456 return EINVAL |
| 457 } |
| 458 pathp, e := UTF16PtrFromString(path) |
| 459 if e != nil { |
| 460 return e |
| 461 } |
| 462 h, e := CreateFile(pathp, |
| 463 FILE_WRITE_ATTRIBUTES, FILE_SHARE_WRITE, nil, |
| 464 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) |
| 465 if e != nil { |
| 466 return e |
| 467 } |
| 468 defer Close(h) |
| 469 a := NsecToFiletime(TimespecToNsec(ts[0])) |
| 470 w := NsecToFiletime(TimespecToNsec(ts[1])) |
| 471 return SetFileTime(h, nil, &a, &w) |
| 472 } |
| 473 |
454 func Fsync(fd Handle) (err error) { | 474 func Fsync(fd Handle) (err error) { |
455 return FlushFileBuffers(fd) | 475 return FlushFileBuffers(fd) |
456 } | 476 } |
457 | 477 |
458 func Chmod(path string, mode uint32) (err error) { | 478 func Chmod(path string, mode uint32) (err error) { |
459 if mode == 0 { | 479 if mode == 0 { |
460 return EINVAL | 480 return EINVAL |
461 } | 481 } |
462 p, e := UTF16PtrFromString(path) | 482 p, e := UTF16PtrFromString(path) |
463 if e != nil { | 483 if e != nil { |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 | 742 |
723 func (w WaitStatus) TrapCause() int { return -1 } | 743 func (w WaitStatus) TrapCause() int { return -1 } |
724 | 744 |
725 // Timespec is an invented structure on Windows, but here for | 745 // Timespec is an invented structure on Windows, but here for |
726 // consistency with the syscall package for other operating systems. | 746 // consistency with the syscall package for other operating systems. |
727 type Timespec struct { | 747 type Timespec struct { |
728 Sec int64 | 748 Sec int64 |
729 Nsec int64 | 749 Nsec int64 |
730 } | 750 } |
731 | 751 |
| 752 func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nse
c) } |
| 753 |
| 754 func NsecToTimespec(nsec int64) (ts Timespec) { |
| 755 ts.Sec = nsec / 1e9 |
| 756 ts.Nsec = nsec % 1e9 |
| 757 return |
| 758 } |
| 759 |
732 // TODO(brainman): fix all needed for net | 760 // TODO(brainman): fix all needed for net |
733 | 761 |
734 func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, EWI
NDOWS } | 762 func Accept(fd Handle) (nfd Handle, sa Sockaddr, err error) { return 0, nil, EWI
NDOWS } |
735 func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error)
{ | 763 func Recvfrom(fd Handle, p []byte, flags int) (n int, from Sockaddr, err error)
{ |
736 return 0, nil, EWINDOWS | 764 return 0, nil, EWINDOWS |
737 } | 765 } |
738 func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) { ret
urn EWINDOWS } | 766 func Sendto(fd Handle, p []byte, flags int, to Sockaddr) (err error) { ret
urn EWINDOWS } |
739 func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { ret
urn EWINDOWS } | 767 func SetsockoptTimeval(fd Handle, level, opt int, tv *Timeval) (err error) { ret
urn EWINDOWS } |
740 | 768 |
741 // The Linger struct is wrong but we only noticed after Go 1. | 769 // The Linger struct is wrong but we only noticed after Go 1. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 | 861 |
834 func (s Signal) String() string { | 862 func (s Signal) String() string { |
835 if 0 <= s && int(s) < len(signals) { | 863 if 0 <= s && int(s) < len(signals) { |
836 str := signals[s] | 864 str := signals[s] |
837 if str != "" { | 865 if str != "" { |
838 return str | 866 return str |
839 } | 867 } |
840 } | 868 } |
841 return "signal " + itoa(int(s)) | 869 return "signal " + itoa(int(s)) |
842 } | 870 } |
OLD | NEW |