iASL,AcpiDump: Improve y/n query for file overwrite

Use fgetc, check for standalone newline.
This commit is contained in:
Robert Moore 2019-08-14 13:37:06 -07:00
parent 361d88d1dd
commit f9eb60ead7
2 changed files with 17 additions and 3 deletions

View File

@ -223,6 +223,7 @@ UtQueryForOverwrite (
char *Pathname)
{
struct stat StatInfo;
int InChar = 0x34;
if (!stat (Pathname, &StatInfo))
@ -230,7 +231,13 @@ UtQueryForOverwrite (
fprintf (stderr, "Target file \"%s\" already exists, overwrite? [y|n] ",
Pathname);
if (getchar () != 'y')
InChar = fgetc (stdin);
if (InChar == '\n')
{
InChar = fgetc (stdin);
}
if ((InChar != 'y') && (InChar != 'Y'))
{
return (FALSE);
}

View File

@ -177,20 +177,27 @@ ApIsExistingFile (
{
#if !defined(_GNU_EFI) && !defined(_EDK2_EFI)
struct stat StatInfo;
int InChar;
if (!stat (Pathname, &StatInfo))
{
fprintf (stderr, "Target path already exists, overwrite? [y|n] ");
if (getchar () != 'y')
InChar = fgetc (stdin);
if (InChar == '\n')
{
InChar = fgetc (stdin);
}
if (InChar != 'y' && InChar != 'Y')
{
return (-1);
}
}
#endif
return 0;
return (0);
}