#include <folly/FileUtil.h>
#include <cerrno>
#include <string>
#include <system_error>
#include <vector>
#include <folly/detail/FileUtilDetail.h>
#include <folly/detail/FileUtilVectorDetail.h>
#include <folly/net/NetOps.h>
#include <folly/portability/Fcntl.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Stdlib.h>
#include <folly/portability/SysFile.h>
#include <folly/portability/SysStat.h>
namespace folly {
namespace {
iovec getIOVecFor(ByteRange);
}
usingnamespacefileutil_detail;
int openNoInt(const char* name, int flags, mode_t mode) { … }
static int filterCloseReturn(int r) { … }
int closeNoInt(int fd) { … }
int closeNoInt(NetworkSocket fd) { … }
int fsyncNoInt(int fd) { … }
int dupNoInt(int fd) { … }
int dup2NoInt(int oldFd, int newFd) { … }
int fdatasyncNoInt(int fd) { … }
int ftruncateNoInt(int fd, off_t len) { … }
int truncateNoInt(const char* path, off_t len) { … }
int flockNoInt(int fd, int operation) { … }
int shutdownNoInt(NetworkSocket fd, int how) { … }
ssize_t readNoInt(int fd, void* buf, size_t count) { … }
ssize_t preadNoInt(int fd, void* buf, size_t count, off_t offset) { … }
ssize_t readvNoInt(int fd, const iovec* iov, int count) { … }
ssize_t preadvNoInt(int fd, const iovec* iov, int count, off_t offset) { … }
ssize_t writeNoInt(int fd, const void* buf, size_t count) { … }
ssize_t pwriteNoInt(int fd, const void* buf, size_t count, off_t offset) { … }
ssize_t writevNoInt(int fd, const iovec* iov, int count) { … }
ssize_t pwritevNoInt(int fd, const iovec* iov, int count, off_t offset) { … }
ssize_t readFull(int fd, void* buf, size_t count) { … }
ssize_t preadFull(int fd, void* buf, size_t count, off_t offset) { … }
ssize_t writeFull(int fd, const void* buf, size_t count) { … }
ssize_t pwriteFull(int fd, const void* buf, size_t count, off_t offset) { … }
#ifndef _WIN32
ssize_t readvFull(int fd, iovec* iov, int count) { … }
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) { … }
ssize_t writevFull(int fd, iovec* iov, int count) { … }
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) { … }
#else
ssize_t readvFull(int fd, iovec* iov, int count) {
return wrapvFull(read, fd, iov, count);
}
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pread, fd, iov, count, offset);
}
ssize_t writevFull(int fd, iovec* iov, int count) {
return wrapvFull(write, fd, iov, count);
}
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pwrite, fd, iov, count, offset);
}
#endif
WriteFileAtomicOptions& WriteFileAtomicOptions::setPermissions(
mode_t _permissions) { … }
WriteFileAtomicOptions& WriteFileAtomicOptions::setSyncType(
SyncType _syncType) { … }
WriteFileAtomicOptions& WriteFileAtomicOptions::setTemporaryDirectory(
std::string _temporaryDirectory) { … }
namespace {
void throwIfWriteFileAtomicFailed(
StringPiece function, StringPiece filename, std::int64_t rc) { … }
int writeFileAtomicNoThrowImpl(
StringPiece filename,
iovec* iov,
int count,
const WriteFileAtomicOptions& options) { … }
}
int writeFileAtomicNoThrow(
StringPiece filename,
iovec* iov,
int count,
mode_t permissions,
SyncType syncType) { … }
int writeFileAtomicNoThrow(
StringPiece filename,
StringPiece data,
const WriteFileAtomicOptions& options) { … }
void writeFileAtomic(
StringPiece filename,
iovec* iov,
int count,
mode_t permissions,
SyncType syncType) { … }
void writeFileAtomic(
StringPiece filename,
ByteRange data,
mode_t permissions,
SyncType syncType) { … }
void writeFileAtomic(
StringPiece filename,
StringPiece data,
mode_t permissions,
SyncType syncType) { … }
void writeFileAtomic(
StringPiece filename,
StringPiece data,
const WriteFileAtomicOptions& options) { … }
namespace {
iovec getIOVecFor(ByteRange byteRange) { … }
}
}