ShellPkg: allow creating of files to create required directory path
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: jaben carsey <jaben.carsey@intel.com> Reviewed-by: Tapan Shah <tapandshah@hp.com> Reviewed-by: Joe Peterson <joe.peterson@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16606 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Provides interface to shell functionality for shell commands and applications.
|
Provides interface to shell functionality for shell commands and applications.
|
||||||
|
|
||||||
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -15,6 +15,7 @@
|
|||||||
#include "UefiShellLib.h"
|
#include "UefiShellLib.h"
|
||||||
#include <ShellBase.h>
|
#include <ShellBase.h>
|
||||||
#include <Library/SortLib.h>
|
#include <Library/SortLib.h>
|
||||||
|
#include <Library/PathLib.h>
|
||||||
|
|
||||||
#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
|
#define FIND_XXXXX_FILE_BUFFER_SIZE (SIZE_OF_EFI_FILE_INFO + MAX_FILE_NAME_LEN)
|
||||||
|
|
||||||
@ -671,6 +672,7 @@ ShellOpenFileByName(
|
|||||||
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
EFI_DEVICE_PATH_PROTOCOL *FilePath;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_FILE_INFO *FileInfo;
|
EFI_FILE_INFO *FileInfo;
|
||||||
|
CHAR16 *FileNameCopy;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ASSERT if FileName is NULL
|
// ASSERT if FileName is NULL
|
||||||
@ -682,11 +684,32 @@ ShellOpenFileByName(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (gEfiShellProtocol != NULL) {
|
if (gEfiShellProtocol != NULL) {
|
||||||
if ((OpenMode & EFI_FILE_MODE_CREATE) == EFI_FILE_MODE_CREATE && (Attributes & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
|
if ((OpenMode & EFI_FILE_MODE_CREATE) == EFI_FILE_MODE_CREATE) {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create only a directory
|
||||||
|
//
|
||||||
|
if ((Attributes & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY) {
|
||||||
return ShellCreateDirectory(FileName, FileHandle);
|
return ShellCreateDirectory(FileName, FileHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Use UEFI Shell 2.0 method
|
// Create the directory to create the file in
|
||||||
|
//
|
||||||
|
FileNameCopy = AllocateCopyPool (StrSize (FileName), FileName);
|
||||||
|
if (FileName == NULL) {
|
||||||
|
return (EFI_OUT_OF_RESOURCES);
|
||||||
|
}
|
||||||
|
PathCleanUpDirectories (FileNameCopy);
|
||||||
|
if (PathRemoveLastItem (FileNameCopy)) {
|
||||||
|
ShellCreateDirectory (FileNameCopy, FileHandle);
|
||||||
|
ShellCloseFile (FileHandle);
|
||||||
|
}
|
||||||
|
SHELL_FREE_NON_NULL (FileNameCopy);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use UEFI Shell 2.0 method to create the file
|
||||||
//
|
//
|
||||||
Status = gEfiShellProtocol->OpenFileByName(FileName,
|
Status = gEfiShellProtocol->OpenFileByName(FileName,
|
||||||
FileHandle,
|
FileHandle,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
## @file
|
## @file
|
||||||
# Provides interface to shell functionality for shell commands and applications.
|
# Provides interface to shell functionality for shell commands and applications.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved. <BR>
|
# Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved. <BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -48,6 +48,7 @@
|
|||||||
UefiLib
|
UefiLib
|
||||||
HiiLib
|
HiiLib
|
||||||
SortLib
|
SortLib
|
||||||
|
PathLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiSimpleFileSystemProtocolGuid # ALWAYS_CONSUMED
|
gEfiSimpleFileSystemProtocolGuid # ALWAYS_CONSUMED
|
||||||
|
Reference in New Issue
Block a user