From 6467e840cafb2e1f1b8f84dbc93cda4b0b6079d2 Mon Sep 17 00:00:00 2001 From: Michihiro NAKAJIMA Date: Mon, 20 Feb 2012 15:31:20 +0900 Subject: [PATCH] Correct console I/O on Windows. Use CONIN$ and CONOUT$ instead of /dev/tty. --- cpio/cpio.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cpio/cpio.c b/cpio/cpio.c index 717476e23..57f4e260d 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -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); -- 2.47.3