...
Source file src/internal/poll/sendfile_windows.go
1
2
3
4
5 package poll
6
7 import "syscall"
8
9
10 func SendFile(fd *FD, src syscall.Handle, n int64) (int64, error) {
11 if fd.kind == kindPipe {
12
13 return 0, syscall.ESPIPE
14 }
15
16 if err := fd.writeLock(); err != nil {
17 return 0, err
18 }
19 defer fd.writeUnlock()
20
21 o := &fd.wop
22 o.qty = uint32(n)
23 o.handle = src
24
25
26 curpos, err := syscall.Seek(o.handle, 0, 1)
27 if err != nil {
28 return 0, err
29 }
30
31 o.o.Offset = uint32(curpos)
32 o.o.OffsetHigh = uint32(curpos >> 32)
33
34 done, err := wsrv.ExecIO(o, func(o *operation) error {
35 return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND)
36 })
37 if err == nil {
38
39
40
41 _, err = syscall.Seek(o.handle, curpos+int64(done), 0)
42 }
43 return int64(done), err
44 }
45
View as plain text