os: implement os.(*File).WriteAt (#3697)

os: implement os.(*File).WriteAt

Signed-off-by: Achille Roussel <achille.roussel@gmail.com>
This commit is contained in:
Achille
2023-05-05 00:40:15 -07:00
committed by GitHub
parent 1d5c5ca2ef
commit 602f35a5ca
8 changed files with 152 additions and 17 deletions
+14
View File
@@ -54,6 +54,15 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
return
}
func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
buf, count := splitSlice(p)
n = libc_pwrite(int32(fd), buf, uint(count), offset)
if n < 0 {
err = getErrno()
}
return
}
func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
newoffset = libc_lseek(int32(fd), offset, whence)
if newoffset < 0 {
@@ -342,6 +351,11 @@ func libc_read(fd int32, buf *byte, count uint) int
//export pread
func libc_pread(fd int32, buf *byte, count uint, offset int64) int
// ssize_t pwrite(int fd, void *buf, size_t count, off_t offset);
//
//export pwrite
func libc_pwrite(fd int32, buf *byte, count uint, offset int64) int
// ssize_t lseek(int fd, off_t offset, int whence);
//
//export lseek