Skip to content

Commit

Permalink
iASL,AcpiDump: Improve y/n query for file overwrite
Browse files Browse the repository at this point in the history
Use fgetc, check for standalone newline.
  • Loading branch information
acpibob committed Aug 14, 2019
1 parent 361d88d commit f9eb60e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion source/compiler/aslutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,21 @@ UtQueryForOverwrite (
char *Pathname)
{
struct stat StatInfo;
int InChar = 0x34;


if (!stat (Pathname, &StatInfo))
{
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);
}
Expand Down
11 changes: 9 additions & 2 deletions source/tools/acpidump/apfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down

0 comments on commit f9eb60e

Please sign in to comment.