/* FUNCTION <>---write a large file from specified position INDEX pwrite64 ANSI_SYNOPSIS #include ssize_t pwrite64(int <[fd]>, void *<[buf]>, size_t <[n]>, loff_t <[off]>); TRAD_SYNOPSIS #include ssize_t pwrite64(<[fd]>, <[buf]>, <[n]>, <[off]>) int <[fd]>; void *<[buf]>; size_t <[n]>; loff_t <[off]>; DESCRIPTION The <> function is similar to <>. The only difference is that it operates on large files and so takes a 64-bit offset. Like <>>, the file position is unchanged by the function (i.e. the file position is the same before and after a call to <>). RETURNS <> returns the number of bytes written or <<-1>> if failure occurred. PORTABILITY <> is an EL/IX extension. Supporting OS subroutine required: <>, <>. */ #include <_ansi.h> #include #include ssize_t _DEFUN (pwrite64, (fd, buf, n, off), int fd _AND _PTR buf _AND size_t n _AND loff_t off) { loff_t cur_pos; _READ_WRITE_RETURN_TYPE num_written; if ((cur_pos = lseek64 (fd, 0, SEEK_CUR)) == (loff_t)-1) return -1; if (lseek64 (fd, off, SEEK_SET) == (loff_t)-1) return -1; num_written = write64 (fd, buf, n); if (lseek64 (fd, cur_pos, SEEK_SET) == (loff_t)-1) return -1; return (ssize_t)num_written; }