Add missing FileUtil functions (p?readvFull, p?writevFull) , add test
[folly.git] / folly / FileUtil.h
index 48e5e7129a5e8e800671b99e3b6b480df0d7562c..5845ba61d385db4b4c6ce97ef0084d135a7b912a 100644 (file)
@@ -32,11 +32,11 @@ int closeNoInt(int fd);
 
 ssize_t readNoInt(int fd, void* buf, size_t n);
 ssize_t preadNoInt(int fd, void* buf, size_t n, off_t offset);
-ssize_t readvNoInt(int fd, const struct iovec* iov, int count);
+ssize_t readvNoInt(int fd, const iovec* iov, int count);
 
 ssize_t writeNoInt(int fd, const void* buf, size_t n);
 ssize_t pwriteNoInt(int fd, const void* buf, size_t n, off_t offset);
-ssize_t writevNoInt(int fd, const struct iovec* iov, int count);
+ssize_t writevNoInt(int fd, const iovec* iov, int count);
 
 /**
  * Wrapper around read() (and pread()) that, in addition to retrying on
@@ -55,10 +55,15 @@ ssize_t writevNoInt(int fd, const struct iovec* iov, int count);
  * contiguous.  You can no longer make this assumption if using readFull().
  * You should probably use pread() when reading from the same file descriptor
  * from multiple threads simultaneously, anyway.
+ *
+ * Note that readvFull and preadvFull require iov to be non-const, unlike
+ * readv and preadv.  The contents of iov after these functions return
+ * is unspecified.
  */
 ssize_t readFull(int fd, void* buf, size_t n);
 ssize_t preadFull(int fd, void* buf, size_t n, off_t offset);
-// TODO(tudorb): add readvFull if needed
+ssize_t readvFull(int fd, iovec* iov, int count);
+ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset);
 
 /**
  * Similar to readFull and preadFull above, wrappers around write() and
@@ -69,10 +74,15 @@ ssize_t preadFull(int fd, void* buf, size_t n, off_t offset);
  * a pipe), POSIX provides stronger guarantees, but not in the general case.
  * For example, Linux (even on a 64-bit platform) won't write more than 2GB in
  * one write() system call.
+ *
+ * Note that writevFull and pwritevFull require iov to be non-const, unlike
+ * writev and pwritev.  The contents of iov after these functions return
+ * is unspecified.
  */
 ssize_t writeFull(int fd, const void* buf, size_t n);
 ssize_t pwriteFull(int fd, const void* buf, size_t n, off_t offset);
-// TODO(tudorb): add writevFull if needed
+ssize_t writevFull(int fd, iovec* iov, int count);
+ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset);
 
 }  // namespaces