@@ -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
@@ -594,6 +595,36 @@ RemoveFileTag(
}
/**
+ 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
user.
@@ -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
Drop TagBuffer in the process. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- .../Application/Shell/ShellParametersProtocol.c | 48 +++++++++++++++------- 1 file changed, 33 insertions(+), 15 deletions(-)