Esempio n. 1
0
File: fd.go Progetto: kshlm/gogfapi
// Write writes len(b) bytes from b into the Fd
//
// Returns number of bytes written on success and error on failure
func (fd *Fd) Write(b []byte) (int, error) {

	n, err := C.glfs_write(fd.fd, unsafe.Pointer(&b[0]), C.size_t(len(b)), 0)
	if n == C.ssize_t(len(b)) {
		// FIXME: errno is set to EINVAL even though write is successful. This
		// is probably a bug. Remove this workaround when that gets fixed.
		err = nil
	}
	return int(n), err

}
Esempio n. 2
0
// Write writes len(b) bytes from b into the Fd
//
// Returns number of bytes written on success and error on failure
func (fd *Fd) Write(b []byte) (int, error) {

	n, err := C.glfs_write(fd.fd, unsafe.Pointer(&b[0]), C.size_t(len(b)), 0)
	return int(n), err

}