]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Attempt to Fix Windows Build Error 2525/head
authorW. Felix Handte <w@felixhandte.com>
Wed, 5 May 2021 17:13:56 +0000 (13:13 -0400)
committerW. Felix Handte <w@felixhandte.com>
Wed, 5 May 2021 17:13:56 +0000 (13:13 -0400)
programs/fileio.c

index 5d7d40ddcc25667ea0579d80f370d90b035a95e3..571b35489594b2c3d2d6a5366c7e9a24ad49cf8e 100644 (file)
@@ -702,14 +702,19 @@ FIO_openDstFile(FIO_ctx_t* fCtx, FIO_prefs_t* const prefs,
         /* Windows requires opening the file as a "binary" file to avoid
          * mangling. This macro doesn't exist on unix. */
         const int openflags = O_WRONLY|O_CREAT|O_TRUNC|O_BINARY;
+        const int fd = _open(dstFileName, openflags, mode);
+        FILE* f = NULL;
+        if (fd != -1) {
+            f = _fdopen(fd, "wb");
+        }
 #else
         const int openflags = O_WRONLY|O_CREAT|O_TRUNC;
-#endif
         const int fd = open(dstFileName, openflags, mode);
         FILE* f = NULL;
         if (fd != -1) {
             f = fdopen(fd, "wb");
         }
+#endif
         if (f == NULL) {
             DISPLAYLEVEL(1, "zstd: %s: %s\n", dstFileName, strerror(errno));
         }