mirror of
https://github.com/acpica/acpica/
synced 2025-02-24 09:24:08 +03:00
iASL,AcpiDump: Improve y/n query for file overwrite
Use fgetc, check for standalone newline.
This commit is contained in:
parent
361d88d1dd
commit
f9eb60ead7
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user