]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
removed regular file test on Windows
authorYann Collet <cyan@fb.com>
Thu, 17 Oct 2019 23:39:47 +0000 (16:39 -0700)
committerYann Collet <cyan@fb.com>
Thu, 17 Oct 2019 23:39:47 +0000 (16:39 -0700)
since it does not work well on this platform
(tested with MinGW).

Note : could be an issue within UTIL_isRegularFile()

programs/fileio.c
programs/fileio.h

index 9efb4aaed3a20c296dcd8b9b196d8368a21a3870..85c04d48fab4e6b116c9600aca83fb36ee43b4d2 100644 (file)
@@ -538,6 +538,8 @@ static FILE* FIO_openSrcFile(const char* srcFileName)
  * @result : FILE* to `dstFileName`, or NULL if it fails */
 static FILE* FIO_openDstFile(FIO_prefs_t* const prefs, const char* srcFileName, const char* dstFileName)
 {
+    if (prefs->testMode) return NULL;  /* do not open file in test mode */
+
     assert(dstFileName != NULL);
     if (!strcmp (dstFileName, stdoutmark)) {
         DISPLAYLEVEL(4,"Using stdout for output \n");
@@ -562,10 +564,14 @@ static FILE* FIO_openDstFile(FIO_prefs_t* const prefs, const char* srcFileName,
     if (UTIL_isRegularFile(dstFileName)) {
         /* Check if destination file already exists */
         FILE* const fCheck = fopen( dstFileName, "rb" );
+#if !defined(_WIN32)
+        /* this test does not work on Windows :
+         * `NUL` and `nul` are detected as regular files */
         if (!strcmp(dstFileName, nulmark)) {
             EXM_THROW(40, "%s is unexpectedly categorized as a regular file",
                         dstFileName);
         }
+#endif
         if (fCheck != NULL) {  /* dst file exists, authorization prompt */
             fclose(fCheck);
             if (!prefs->overwrite) {
index cb3d64c56d777e51bdaf3df03b853cfbbbdad070..4b0143beb3ba9bad171f1a6b9b17ead28dc9c093 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #define stdinmark  "/*stdin*\\"
 #define stdoutmark "/*stdout*\\"
 #ifdef _WIN32
-#  define nulmark "nul"
+#  define nulmark "NUL"
 #else
 #  define nulmark "/dev/null"
 #endif