X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FFileUtil.cpp;h=728f1d268dce82aa4f47bef8ee4dff14c0c19b38;hb=19d24e21568ec8e04da748dbe815f046a327f274;hp=4a4ca6b6264658c434e4707daeff7806b36fa973;hpb=ea2da05cd8b5f6700e92822740982ee2597ea01a;p=folly.git diff --git a/folly/FileUtil.cpp b/folly/FileUtil.cpp index 4a4ca6b6..728f1d26 100644 --- a/folly/FileUtil.cpp +++ b/folly/FileUtil.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2013 Facebook, Inc. + * Copyright 2015 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,16 @@ * limitations under the License. */ -#include "folly/FileUtil.h" +#include #include #ifdef __APPLE__ #include #endif +#include +#include -#include "folly/detail/FileUtilDetail.h" +#include namespace folly { @@ -41,7 +43,7 @@ int closeNoInt(int fd) { // Interestingly enough, the Single Unix Specification says that the state // of the file descriptor is unspecified if close returns EINTR. In that // case, the safe thing to do is also not to retry close() -- leaking a file - // descriptor is probably better than closing the wrong file. + // descriptor is definitely better than closing the wrong file. if (r == -1 && errno == EINTR) { r = 0; } @@ -52,10 +54,18 @@ int fsyncNoInt(int fd) { return wrapNoInt(fsync, fd); } +int dupNoInt(int fd) { + return wrapNoInt(dup, fd); +} + +int dup2NoInt(int oldfd, int newfd) { + return wrapNoInt(dup2, oldfd, 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); @@ -70,6 +80,14 @@ int truncateNoInt(const char* path, off_t len) { return wrapNoInt(truncate, path, len); } +int flockNoInt(int fd, int operation) { + return wrapNoInt(flock, fd, operation); +} + +int shutdownNoInt(int fd, int how) { + return wrapNoInt(shutdown, fd, how); +} + ssize_t readNoInt(int fd, void* buf, size_t count) { return wrapNoInt(read, fd, buf, count); } @@ -114,7 +132,7 @@ ssize_t readvFull(int fd, iovec* iov, int count) { return wrapvFull(readv, fd, iov, count); } -#ifdef FOLLY_HAVE_PREADV +#if FOLLY_HAVE_PREADV ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) { return wrapvFull(preadv, fd, iov, count, offset); } @@ -124,11 +142,10 @@ ssize_t writevFull(int fd, iovec* iov, int count) { return wrapvFull(writev, fd, iov, count); } -#ifdef FOLLY_HAVE_PWRITEV +#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 -