Revision: 14394
http://edk2.svn.sourceforge.net/edk2/?rev=14394&view=rev
Author: ydong10
Date: 2013-06-04 01:06:22 +0000 (Tue, 04 Jun 2013)
Log Message:
-----------
ShellPkg: refine the logic for cp command
Signed-off-by: Eric Dong <[email protected]>
Reviewed-by: Jaben Carsey <[email protected]>
Reviewed-by: Erik Bjorge <[email protected]>
Modified Paths:
--------------
trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
Modified: trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
===================================================================
--- trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c 2013-05-29
14:56:35 UTC (rev 14393)
+++ trunk/edk2/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c 2013-06-04
01:06:22 UTC (rev 14394)
@@ -315,11 +315,6 @@
ASSERT(DestDir != NULL);
//
- // We already verified that this was present.
- //
- ASSERT(Cwd != NULL);
-
- //
// If we are trying to copy multiple files... make sure we got a directory
for the target...
//
if (EFI_ERROR(ShellIsDirectory(DestDir)) && FileList->Link.ForwardLink !=
FileList->Link.BackLink) {
@@ -342,7 +337,7 @@
NewSize = StrSize(DestDir);
NewSize += StrSize(Node->FullName);
- NewSize += StrSize(Cwd);
+ NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);
if (NewSize > PathLen) {
PathLen = NewSize;
}
@@ -405,7 +400,12 @@
//
// simple copy of a single file
//
- StrCpy(DestPath, Cwd);
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
StrCat(DestPath, L"\\");
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] ==
L'\\') {
@@ -424,15 +424,25 @@
// Check for leading slash
//
if (DestDir[0] == L'\\') {
- //
- // Copy to the root of CWD
- //
- StrCpy(DestPath, Cwd);
+ //
+ // Copy to the root of CWD
+ //
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
while (PathRemoveLastItem(DestPath));
StrCat(DestPath, DestDir+1);
StrCat(DestPath, Node->FileName);
} else if (StrStr(DestDir, L":") == NULL) {
- StrCpy(DestPath, Cwd);
+ if (Cwd != NULL) {
+ StrCpy(DestPath, Cwd);
+ } else {
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF),
gShellLevel2HiiHandle, DestDir);
+ return (SHELL_INVALID_PARAMETER);
+ }
if (DestPath[StrLen(DestPath)-1] != L'\\' && DestDir[0] != L'\\') {
StrCat(DestPath, L"\\");
} else if (DestPath[StrLen(DestPath)-1] == L'\\' && DestDir[0] ==
L'\\') {
@@ -562,7 +572,7 @@
SHELL_FREE_NON_NULL(FileInfo);
ShellCloseFileMetaArg(&List);
} else {
- ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode,
RecursiveMode, NULL);
+ ShellStatus = ValidateAndCopyFiles(FileList, DestDir, SilentMode,
RecursiveMode, NULL);
}
return (ShellStatus);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits