From 82c7a7a4baf4a7a15381ee720799dc41c3d54909 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Tue, 31 Mar 2015 22:41:37 +0100 Subject: Fix RISC OS not having a pread/pwrite implementation. --- utils/utils.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 5c8acd6f0..722e32302 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "utils/config.h" #include "utils/log.h" @@ -628,3 +629,34 @@ nserror nsc_snptimet(char *str, size_t size, time_t *timep) return NSERROR_OK; } + +#ifndef HAVE_PREAD + +ssize_t pread(int fd, void *buf, size_t count, off_t offset) +{ + off_t sk; + + sk = lseek(fd, offset, SEEK_SET); + if (sk == -1) { + return (off_t)-1; + } + return read(fd, buf, count); +} + +#endif + + +#ifndef HAVE_PWRITE + +ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset) +{ + off_t sk; + + sk = lseek(fd, offset, SEEK_SET); + if (sk == (off_t)-1) { + return -1; + } + return write(fd, buf, count); +} + +#endif -- cgit v1.2.3