/* Determine if a file name represents a unicode file. */
EFI_STATUS IsUnicodeFile(IN CONST CHAR16 *FileName)
/* Determine if a file name represents a unicode file. */
EFI_STATUS IsUnicodeFile(IN CONST CHAR16 *FileName)
{
  SHELL_FILE_HANDLE  Handle;
  EFI_STATUS         Status;
  UINT64             OriginalFilePosition;
  UINTN              CharSize;
  CHAR16             CharBuffer;
  Status = gEfiShellProtocol->OpenFileByName (FileName, &Handle, EFI_FILE_MODE_READ);
  if (EFI_ERROR (Status)) {
    return (Status);
  }
  gEfiShellProtocol->GetFilePosition (Handle, &OriginalFilePosition);
  gEfiShellProtocol->SetFilePosition (Handle, 0);
  CharSize = sizeof (CHAR16);
  Status   = gEfiShellProtocol->ReadFile (Handle, &CharSize, &CharBuffer);
  if (EFI_ERROR (Status) || (CharBuffer != gUnicodeFileTag)) {
    Status = EFI_BUFFER_TOO_SMALL;
  }
  gEfiShellProtocol->SetFilePosition (Handle, OriginalFilePosition);
  gEfiShellProtocol->CloseFile (Handle);
  return (Status);
}