]> 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 06:31:20 +0000 (15:31 +0900)
cpio/cpio.c

index 717476e2317af3bf7ca6d0afcb4d3108b6f978e2..57f4e260dae0913c722fa0c118dbda40dfeaeed3 100644 (file)
@@ -1152,12 +1152,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);