summaryrefslogtreecommitdiffstats
path: root/util/system/file.cpp
diff options
context:
space:
mode:
authormelkov <[email protected]>2022-02-10 16:48:13 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:48:13 +0300
commit438546c8737d5c1fdeb31157dcf999717d930eec (patch)
treed29d229abd2f9f889b9b7eb148d635059dc26acf /util/system/file.cpp
parent96647fad5355ff5ef45a00a6d85c097028584ab0 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'util/system/file.cpp')
-rw-r--r--util/system/file.cpp64
1 files changed, 32 insertions, 32 deletions
diff --git a/util/system/file.cpp b/util/system/file.cpp
index 4a261d020cb..ec7cc69272e 100644
--- a/util/system/file.cpp
+++ b/util/system/file.cpp
@@ -49,7 +49,7 @@
#include <sys/sendfile.h>
#define HAVE_POSIX_FADVISE 1
#define HAVE_SYNC_FILE_RANGE 1
-#elif defined(__FreeBSD__) && !defined(WITH_VALGRIND)
+#elif defined(__FreeBSD__) && !defined(WITH_VALGRIND)
#include <sys/param.h>
#define HAVE_POSIX_FADVISE (__FreeBSD_version >= 900501)
#define HAVE_SYNC_FILE_RANGE 0
@@ -565,38 +565,38 @@ FHANDLE TFileHandle::Duplicate() const noexcept {
#endif
}
-int TFileHandle::Duplicate2Posix(int dstHandle) const noexcept {
- if (!IsOpen()) {
- return -1;
- }
-#if defined(_win_)
- FHANDLE dupHandle = Duplicate();
- if (dupHandle == INVALID_FHANDLE) {
- _set_errno(EMFILE);
- return -1;
- }
- int posixHandle = _open_osfhandle((intptr_t)dupHandle, 0);
- if (posixHandle == -1) {
- CloseHandle(dupHandle);
- return -1;
- }
- if (dup2(posixHandle, dstHandle) == -1) {
- dstHandle = -1;
- }
- _close(posixHandle);
- return dstHandle;
-#elif defined(_unix_)
- while (dup2(Fd_, dstHandle) == -1) {
- if (errno != EINTR) {
- return -1;
- }
- }
- return dstHandle;
-#else
+int TFileHandle::Duplicate2Posix(int dstHandle) const noexcept {
+ if (!IsOpen()) {
+ return -1;
+ }
+#if defined(_win_)
+ FHANDLE dupHandle = Duplicate();
+ if (dupHandle == INVALID_FHANDLE) {
+ _set_errno(EMFILE);
+ return -1;
+ }
+ int posixHandle = _open_osfhandle((intptr_t)dupHandle, 0);
+ if (posixHandle == -1) {
+ CloseHandle(dupHandle);
+ return -1;
+ }
+ if (dup2(posixHandle, dstHandle) == -1) {
+ dstHandle = -1;
+ }
+ _close(posixHandle);
+ return dstHandle;
+#elif defined(_unix_)
+ while (dup2(Fd_, dstHandle) == -1) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ }
+ return dstHandle;
+#else
#error unsupported platform
-#endif
-}
-
+#endif
+}
+
bool TFileHandle::LinkTo(const TFileHandle& fh) const noexcept {
#if defined(_unix_)
while (dup2(fh.Fd_, Fd_) == -1) {