func (fd *FD) Read(b *[]byte) (ret int, err *Error) {
if fd == nil {
- return -1, EINVAL
+ return 0, EINVAL
}
var r, e int64;
if len(b) > 0 { // because we access b[0]
r, e = syscall.read(fd.fd, &b[0], int64(len(b)));
+ if r < 0 {
+ r = 0
+ }
}
return int(r), ErrnoToError(e)
}
func (fd *FD) Write(b *[]byte) (ret int, err *Error) {
if fd == nil {
- return -1, EINVAL
+ return 0, EINVAL
}
var r, e int64;
if len(b) > 0 { // because we access b[0]
r, e = syscall.write(fd.fd, &b[0], int64(len(b)));
+ if r < 0 {
+ r = 0
+ }
}
return int(r), ErrnoToError(e)
}
func (fd *FD) WriteString(s string) (ret int, err *Error) {
if fd == nil {
- return -1, EINVAL
+ return 0, EINVAL
}
b := new([]byte, len(s)+1);
if !syscall.StringToBytes(b, s) {
- return -1, EINVAL
+ return 0, EINVAL
}
r, e := syscall.write(fd.fd, &b[0], int64(len(s)));
+ if r < 0 {
+ r = 0
+ }
return int(r), ErrnoToError(e)
}