]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Correct console I/O on Windows. Use CONIN$ and CONOUT$ instead of /dev/tty.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 20 Feb 2012 06:31:20 +0000 (15:31 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Mon, 20 Feb 2012 20:22:07 +0000 (05:22 +0900)
cpio/cpio.c

index 025c50cfafd2af65f94ecbf68406453b6349ce43..b3f631751acf2aeec7e39efe5f94945b1bda3d38 100644 (file)
@@ -1139,12 +1139,24 @@ cpio_rename(const char *name)
        static char buff[1024];
        FILE *t;
        char *p, *ret;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+       FILE *to;
 
+       t = fopen("CONIN$", "r");
+       if (t == NULL)
+               return (name);
+       to = fopen("CONOUT$", "w");
+       if (to == NULL)
+               return (name);
+       fprintf(to, "%s (Enter/./(new name))? ", name);
+       fclose(to);
+#else
        t = fopen("/dev/tty", "r+");
        if (t == NULL)
                return (name);
        fprintf(t, "%s (Enter/./(new name))? ", name);
        fflush(t);
+#endif
 
        p = fgets(buff, sizeof(buff), t);
        fclose(t);