1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-05 19:15:58 +03:00

fix confirmation prompt

This commit is contained in:
Yann Collet
2015-12-29 11:57:15 +01:00
parent 1ac364d60b
commit c1450f721d

View File

@@ -225,7 +225,6 @@ static int FIO_getFiles(FILE** fileOutPtr, FILE** fileInPtr,
if (*fileOutPtr != 0) if (*fileOutPtr != 0)
{ {
/* prompt for overwrite authorization */ /* prompt for overwrite authorization */
int ch = 'N';
fclose(*fileOutPtr); fclose(*fileOutPtr);
DISPLAY("Warning : %s already exists \n", dstFileName); DISPLAY("Warning : %s already exists \n", dstFileName);
if ((g_displayLevel <= 1) || (*fileInPtr == stdin)) if ((g_displayLevel <= 1) || (*fileInPtr == stdin))
@@ -235,11 +234,14 @@ static int FIO_getFiles(FILE** fileOutPtr, FILE** fileInPtr,
return 1; return 1;
} }
DISPLAY("Overwrite ? (y/N) : "); DISPLAY("Overwrite ? (y/N) : ");
while((ch = getchar()) != '\n' && ch != EOF); /* flush integrated */
if ((ch!='Y') && (ch!='y'))
{ {
DISPLAY("No. Operation aborted : %s already exists \n", dstFileName); int ch = getchar();
return 1; if ((ch!='Y') && (ch!='y'))
{
DISPLAY("No. Operation aborted : %s already exists \n", dstFileName);
return 1;
}
while ((ch!=EOF) && (ch!='\n')) ch = getchar(); /* flush rest of input line */
} }
} }
} }