get_or_throw(map, key) returns references
[folly.git] / folly / FileUtil.cpp
index 6ef48e85c5d97460da02914a626e64c383a24b73..71eee1d88f039d0839b3cd67ec22c5c32f6bc3ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
-#include "folly/FileUtil.h"
+#include <folly/FileUtil.h>
 
 #include <cerrno>
-#ifdef __APPLE__
-#include <fcntl.h>
-#endif
-#include <sys/file.h>
-#include <sys/socket.h>
 
-#include "folly/detail/FileUtilDetail.h"
+#include <folly/detail/FileUtilDetail.h>
+#include <folly/portability/Fcntl.h>
+#include <folly/portability/Sockets.h>
+#include <folly/portability/SysFile.h>
 
 namespace folly {
 
@@ -65,7 +63,7 @@ int dup2NoInt(int oldfd, int newfd) {
 int fdatasyncNoInt(int fd) {
 #if defined(__APPLE__)
   return wrapNoInt(fcntl, fd, F_FULLFSYNC);
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(_MSC_VER)
   return wrapNoInt(fsync, fd);
 #else
   return wrapNoInt(fdatasync, fd);
@@ -97,7 +95,7 @@ ssize_t preadNoInt(int fd, void* buf, size_t count, off_t offset) {
 }
 
 ssize_t readvNoInt(int fd, const iovec* iov, int count) {
-  return wrapNoInt(writev, fd, iov, count);
+  return wrapNoInt(readv, fd, iov, count);
 }
 
 ssize_t writeNoInt(int fd, const void* buf, size_t count) {
@@ -132,21 +130,16 @@ ssize_t readvFull(int fd, iovec* iov, int count) {
   return wrapvFull(readv, fd, iov, count);
 }
 
-#if FOLLY_HAVE_PREADV
 ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
   return wrapvFull(preadv, fd, iov, count, offset);
 }
-#endif
 
 ssize_t writevFull(int fd, iovec* iov, int count) {
   return wrapvFull(writev, fd, iov, count);
 }
 
-#if FOLLY_HAVE_PWRITEV
 ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
   return wrapvFull(pwritev, fd, iov, count, offset);
 }
-#endif
 
 }  // namespaces
-