ShellPkg: UpdateStdInStdOutStdErr(): extract WriteFileTag()

Drop TagBuffer in the process.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15724 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Laszlo Ersek 2014-07-31 15:44:30 +00:00 committed by jljusten
parent 3a8e175b33
commit 94c2a04449
1 changed files with 33 additions and 15 deletions

View File

@ -2,6 +2,7 @@
Member functions of EFI_SHELL_PARAMETERS_PROTOCOL and functions for creation,
manipulation, and initialization of EFI_SHELL_PARAMETERS_PROTOCOL.
Copyright (C) 2014, Red Hat, Inc.
Copyright (c) 2013 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
@ -593,6 +594,36 @@ RemoveFileTag(
return (EFI_SUCCESS);
}
/**
Write the unicode file tag to the specified file.
It is the caller's responsibility to ensure that
ShellInfoObject.NewEfiShellProtocol has been initialized before calling this
function.
@param[in] FileHandle The file to write the unicode file tag to.
@return Status code from ShellInfoObject.NewEfiShellProtocol->WriteFile.
**/
STATIC
EFI_STATUS
WriteFileTag (
IN SHELL_FILE_HANDLE FileHandle
)
{
CHAR16 FileTag;
UINTN Size;
EFI_STATUS Status;
FileTag = gUnicodeFileTag;
Size = sizeof FileTag;
Status = ShellInfoObject.NewEfiShellProtocol->WriteFile (FileHandle, &Size,
&FileTag);
ASSERT (EFI_ERROR (Status) || Size == sizeof FileTag);
return Status;
}
/**
Funcion will replace the current StdIn and StdOut in the ShellParameters protocol
structure by parsing NewCommandLine. The current values are returned to the
@ -638,7 +669,6 @@ UpdateStdInStdOutStdErr(
BOOLEAN OutAppend;
BOOLEAN ErrAppend;
UINTN Size;
CHAR16 TagBuffer[2];
SPLIT_LIST *Split;
CHAR16 *FirstLocation;
@ -1050,13 +1080,7 @@ UpdateStdInStdOutStdErr(
}
Status = ShellOpenFileByName(StdErrFileName, &TempHandle, EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ|EFI_FILE_MODE_CREATE,0);
if (!ErrAppend && ErrUnicode && !EFI_ERROR(Status)) {
//
// Write out the gUnicodeFileTag
//
Size = sizeof(CHAR16);
TagBuffer[0] = gUnicodeFileTag;
TagBuffer[1] = CHAR_NULL;
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
Status = WriteFileTag (TempHandle);
}
if (!ErrUnicode && !EFI_ERROR(Status)) {
TempHandle = CreateFileInterfaceFile(TempHandle, FALSE);
@ -1085,13 +1109,7 @@ UpdateStdInStdOutStdErr(
if (StrStr(StdOutFileName, L"NUL")==StdOutFileName) {
//no-op
} else if (!OutAppend && OutUnicode && !EFI_ERROR(Status)) {
//
// Write out the gUnicodeFileTag
//
Size = sizeof(CHAR16);
TagBuffer[0] = gUnicodeFileTag;
TagBuffer[1] = CHAR_NULL;
ShellInfoObject.NewEfiShellProtocol->WriteFile(TempHandle, &Size, TagBuffer);
Status = WriteFileTag (TempHandle);
} else if (OutAppend) {
//
// Move to end of file