Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (22 months ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/Cp.c
r80721 r99404 30 30 **/ 31 31 SHELL_STATUS 32 ValidateAndCopyFiles (32 ValidateAndCopyFiles ( 33 33 IN CONST EFI_SHELL_FILE_INFO *FileList, 34 34 IN CONST CHAR16 *DestDir, … … 52 52 **/ 53 53 SHELL_STATUS 54 CopySingleFile (55 IN CONST CHAR16 *Source,56 IN CONST CHAR16 *Dest,57 OUT VOID **Resp,58 IN BOOLEAN SilentMode,59 IN CONST CHAR16 *CmdName54 CopySingleFile ( 55 IN CONST CHAR16 *Source, 56 IN CONST CHAR16 *Dest, 57 OUT VOID **Resp, 58 IN BOOLEAN SilentMode, 59 IN CONST CHAR16 *CmdName 60 60 ) 61 61 { … … 76 76 UINTN DestVolumeInfoSize; 77 77 78 ASSERT (Resp != NULL);79 80 SourceHandle 81 DestHandle 82 Response 83 List 84 DestVolumeInfo 85 ShellStatus 86 87 ReadSize = PcdGet32 (PcdShellFileOperationSize);78 ASSERT (Resp != NULL); 79 80 SourceHandle = NULL; 81 DestHandle = NULL; 82 Response = *Resp; 83 List = NULL; 84 DestVolumeInfo = NULL; 85 ShellStatus = SHELL_SUCCESS; 86 87 ReadSize = PcdGet32 (PcdShellFileOperationSize); 88 88 // Why bother copying a file to itself 89 if (StrCmp (Source, Dest) == 0) {89 if (StrCmp (Source, Dest) == 0) { 90 90 return (SHELL_SUCCESS); 91 91 } … … 94 94 // if the destination file existed check response and possibly prompt user 95 95 // 96 if (ShellFileExists(Dest) == EFI_SUCCESS) { 97 if (Response == NULL && !SilentMode) { 98 Status = ShellPromptForResponseHii(ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response); 99 } 96 if (ShellFileExists (Dest) == EFI_SUCCESS) { 97 if ((Response == NULL) && !SilentMode) { 98 Status = ShellPromptForResponseHii (ShellPromptResponseTypeYesNoAllCancel, STRING_TOKEN (STR_GEN_DEST_EXIST_OVR), gShellLevel2HiiHandle, &Response); 99 } 100 100 101 // 101 102 // possibly return based on response … … 105 106 return SHELL_ABORTED; 106 107 } 107 switch (*(SHELL_PROMPT_RESPONSE*)Response) { 108 109 switch (*(SHELL_PROMPT_RESPONSE *)Response) { 108 110 case ShellPromptResponseNo: 109 111 // … … 127 129 } 128 130 129 if (ShellIsDirectory (Source) == EFI_SUCCESS) {130 Status = ShellCreateDirectory (Dest, &DestHandle);131 if (EFI_ERROR (Status)) {132 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest);131 if (ShellIsDirectory (Source) == EFI_SUCCESS) { 132 Status = ShellCreateDirectory (Dest, &DestHandle); 133 if (EFI_ERROR (Status)) { 134 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_DIR_FAIL), gShellLevel2HiiHandle, CmdName, Dest); 133 135 return (SHELL_ACCESS_DENIED); 134 136 } … … 137 139 // Now copy all the files under the directory... 138 140 // 139 TempName 140 Size 141 StrnCatGrow (&TempName, &Size, Source, 0);142 StrnCatGrow (&TempName, &Size, L"\\*", 0);141 TempName = NULL; 142 Size = 0; 143 StrnCatGrow (&TempName, &Size, Source, 0); 144 StrnCatGrow (&TempName, &Size, L"\\*", 0); 143 145 if (TempName != NULL) { 144 ShellOpenFileMetaArg ((CHAR16*)TempName, EFI_FILE_MODE_READ, &List);146 ShellOpenFileMetaArg ((CHAR16 *)TempName, EFI_FILE_MODE_READ, &List); 145 147 *TempName = CHAR_NULL; 146 StrnCatGrow (&TempName, &Size, Dest, 0);147 StrnCatGrow (&TempName, &Size, L"\\", 0);148 ShellStatus = ValidateAndCopyFiles (List, TempName, SilentMode, TRUE, Resp);149 ShellCloseFileMetaArg (&List);150 SHELL_FREE_NON_NULL (TempName);148 StrnCatGrow (&TempName, &Size, Dest, 0); 149 StrnCatGrow (&TempName, &Size, L"\\", 0); 150 ShellStatus = ValidateAndCopyFiles (List, TempName, SilentMode, TRUE, Resp); 151 ShellCloseFileMetaArg (&List); 152 SHELL_FREE_NON_NULL (TempName); 151 153 Size = 0; 152 154 } 153 155 } else { 154 Status = ShellDeleteFileByName (Dest);156 Status = ShellDeleteFileByName (Dest); 155 157 156 158 // 157 159 // open file with create enabled 158 160 // 159 Status = ShellOpenFileByName (Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);160 if (EFI_ERROR (Status)) {161 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest);161 Status = ShellOpenFileByName (Dest, &DestHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0); 162 if (EFI_ERROR (Status)) { 163 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_OPEN_FAIL), gShellLevel2HiiHandle, CmdName, Dest); 162 164 return (SHELL_ACCESS_DENIED); 163 165 } … … 173 175 174 176 // 175 // get file size of source file and freespace available on destination volume176 // 177 ShellGetFileSize (SourceHandle, &SourceFileSize);178 ShellGetFileSize (DestHandle, &DestFileSize);179 180 // 181 // if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space182 // 183 if (DestFileSize < SourceFileSize){177 // get file size of source file and freespace available on destination volume 178 // 179 ShellGetFileSize (SourceHandle, &SourceFileSize); 180 ShellGetFileSize (DestHandle, &DestFileSize); 181 182 // 183 // if the destination file already exists then it will be replaced, meaning the sourcefile effectively needs less storage space 184 // 185 if (DestFileSize < SourceFileSize) { 184 186 SourceFileSize -= DestFileSize; 185 187 } else { … … 188 190 189 191 // 190 // get the system volume info to check the free space191 // 192 DestVolumeFP = ConvertShellHandleToEfiFileProtocol(DestHandle);193 DestVolumeInfo = NULL;192 // get the system volume info to check the free space 193 // 194 DestVolumeFP = ConvertShellHandleToEfiFileProtocol (DestHandle); 195 DestVolumeInfo = NULL; 194 196 DestVolumeInfoSize = 0; 195 Status = DestVolumeFP->GetInfo(196 DestVolumeFP,197 &gEfiFileSystemInfoGuid,198 &DestVolumeInfoSize,199 DestVolumeInfo200 );197 Status = DestVolumeFP->GetInfo ( 198 DestVolumeFP, 199 &gEfiFileSystemInfoGuid, 200 &DestVolumeInfoSize, 201 DestVolumeInfo 202 ); 201 203 202 204 if (Status == EFI_BUFFER_TOO_SMALL) { 203 DestVolumeInfo = AllocateZeroPool (DestVolumeInfoSize);204 Status = DestVolumeFP->GetInfo(205 DestVolumeFP,206 &gEfiFileSystemInfoGuid,207 &DestVolumeInfoSize,208 DestVolumeInfo209 );210 } 211 212 // 213 // check if enough space available on destination drive to complete copy214 // 215 if ( DestVolumeInfo!= NULL&& (DestVolumeInfo->FreeSpace < SourceFileSize)) {216 // 217 // not enough space on destination directory to copy file218 // 219 SHELL_FREE_NON_NULL (DestVolumeInfo);220 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName);221 return (SHELL_VOLUME_FULL);205 DestVolumeInfo = AllocateZeroPool (DestVolumeInfoSize); 206 Status = DestVolumeFP->GetInfo ( 207 DestVolumeFP, 208 &gEfiFileSystemInfoGuid, 209 &DestVolumeInfoSize, 210 DestVolumeInfo 211 ); 212 } 213 214 // 215 // check if enough space available on destination drive to complete copy 216 // 217 if ((DestVolumeInfo != NULL) && (DestVolumeInfo->FreeSpace < SourceFileSize)) { 218 // 219 // not enough space on destination directory to copy file 220 // 221 SHELL_FREE_NON_NULL (DestVolumeInfo); 222 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_FAIL), gShellLevel2HiiHandle, CmdName); 223 return (SHELL_VOLUME_FULL); 222 224 } else { 223 225 // 224 226 // copy data between files 225 227 // 226 Buffer = AllocateZeroPool (ReadSize);228 Buffer = AllocateZeroPool (ReadSize); 227 229 if (Buffer == NULL) { 228 230 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, CmdName); 229 231 return SHELL_OUT_OF_RESOURCES; 230 232 } 231 while (ReadSize == PcdGet32(PcdShellFileOperationSize) && !EFI_ERROR(Status)) { 232 Status = ShellReadFile(SourceHandle, &ReadSize, Buffer); 233 if (!EFI_ERROR(Status)) { 234 Status = ShellWriteFile(DestHandle, &ReadSize, Buffer); 235 if (EFI_ERROR(Status)) { 236 ShellStatus = (SHELL_STATUS) (Status & (~MAX_BIT)); 237 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest); 233 234 while (ReadSize == PcdGet32 (PcdShellFileOperationSize) && !EFI_ERROR (Status)) { 235 Status = ShellReadFile (SourceHandle, &ReadSize, Buffer); 236 if (!EFI_ERROR (Status)) { 237 Status = ShellWriteFile (DestHandle, &ReadSize, Buffer); 238 if (EFI_ERROR (Status)) { 239 ShellStatus = (SHELL_STATUS)(Status & (~MAX_BIT)); 240 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_WRITE_ERROR), gShellLevel2HiiHandle, CmdName, Dest); 238 241 break; 239 242 } 240 243 } else { 241 ShellStatus = (SHELL_STATUS) 242 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source);244 ShellStatus = (SHELL_STATUS)(Status & (~MAX_BIT)); 245 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_CPY_READ_ERROR), gShellLevel2HiiHandle, CmdName, Source); 243 246 break; 244 247 } 245 248 } 246 249 } 247 SHELL_FREE_NON_NULL(DestVolumeInfo); 250 251 SHELL_FREE_NON_NULL (DestVolumeInfo); 248 252 } 249 253 … … 252 256 // 253 257 if (DestHandle != NULL) { 254 ShellCloseFile(&DestHandle); 255 DestHandle = NULL; 256 } 258 ShellCloseFile (&DestHandle); 259 DestHandle = NULL; 260 } 261 257 262 if (SourceHandle != NULL) { 258 ShellCloseFile (&SourceHandle);263 ShellCloseFile (&SourceHandle); 259 264 SourceHandle = NULL; 260 265 } … … 287 292 **/ 288 293 SHELL_STATUS 289 ValidateAndCopyFiles (294 ValidateAndCopyFiles ( 290 295 IN CONST EFI_SHELL_FILE_INFO *FileList, 291 296 IN CONST CHAR16 *DestDir, … … 295 300 ) 296 301 { 297 CHAR16 *HiiOutput;298 CHAR16 *HiiResultOk;299 CONST EFI_SHELL_FILE_INFO *Node;300 SHELL_STATUS ShellStatus;301 EFI_STATUS Status;302 CHAR16 *DestPath;303 VOID *Response;304 UINTN PathSize;305 CONST CHAR16 *Cwd;306 UINTN NewSize;307 CHAR16 *CleanFilePathStr;302 CHAR16 *HiiOutput; 303 CHAR16 *HiiResultOk; 304 CONST EFI_SHELL_FILE_INFO *Node; 305 SHELL_STATUS ShellStatus; 306 EFI_STATUS Status; 307 CHAR16 *DestPath; 308 VOID *Response; 309 UINTN PathSize; 310 CONST CHAR16 *Cwd; 311 UINTN NewSize; 312 CHAR16 *CleanFilePathStr; 308 313 309 314 if (Resp == NULL) { … … 316 321 ShellStatus = SHELL_SUCCESS; 317 322 PathSize = 0; 318 Cwd = ShellGetCurrentDir (NULL);323 Cwd = ShellGetCurrentDir (NULL); 319 324 CleanFilePathStr = NULL; 320 325 321 ASSERT(FileList != NULL); 322 ASSERT(DestDir != NULL); 323 326 ASSERT (FileList != NULL); 327 ASSERT (DestDir != NULL); 324 328 325 329 Status = ShellLevel2StripQuotes (DestDir, &CleanFilePathStr); … … 337 341 // If we are trying to copy multiple files... make sure we got a directory for the target... 338 342 // 339 if (EFI_ERROR (ShellIsDirectory(CleanFilePathStr)) && FileList->Link.ForwardLink != FileList->Link.BackLink) {343 if (EFI_ERROR (ShellIsDirectory (CleanFilePathStr)) && (FileList->Link.ForwardLink != FileList->Link.BackLink)) { 340 344 // 341 345 // Error for destination not a directory 342 346 // 343 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);347 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); 344 348 FreePool (CleanFilePathStr); 345 349 return (SHELL_INVALID_PARAMETER); 346 350 } 347 for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link) 348 ; !IsNull(&FileList->Link, &Node->Link) 349 ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link) 350 ){ 351 352 for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link) 353 ; !IsNull (&FileList->Link, &Node->Link) 354 ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link) 355 ) 356 { 351 357 // 352 358 // skip the directory traversing stuff... 353 359 // 354 if ( StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {360 if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) { 355 361 continue; 356 362 } 357 363 358 NewSize = StrSize(CleanFilePathStr);359 NewSize += StrSize (Node->FullName);360 NewSize += (Cwd == NULL) ? 0 : (StrSize(Cwd) + sizeof(CHAR16));364 NewSize = StrSize (CleanFilePathStr); 365 NewSize += StrSize (Node->FullName); 366 NewSize += (Cwd == NULL) ? 0 : (StrSize (Cwd) + sizeof (CHAR16)); 361 367 if (NewSize > PathSize) { 362 368 PathSize = NewSize; … … 366 372 // Make sure got -r if required 367 373 // 368 if (!RecursiveMode && !EFI_ERROR (ShellIsDirectory(Node->FullName))) {369 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp");374 if (!RecursiveMode && !EFI_ERROR (ShellIsDirectory (Node->FullName))) { 375 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_REQ), gShellLevel2HiiHandle, L"cp"); 370 376 FreePool (CleanFilePathStr); 371 377 return (SHELL_INVALID_PARAMETER); … … 375 381 // make sure got dest as dir if needed 376 382 // 377 if (!EFI_ERROR (ShellIsDirectory(Node->FullName)) && EFI_ERROR(ShellIsDirectory(CleanFilePathStr))) {383 if (!EFI_ERROR (ShellIsDirectory (Node->FullName)) && EFI_ERROR (ShellIsDirectory (CleanFilePathStr))) { 378 384 // 379 385 // Error for destination not a directory 380 386 // 381 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);387 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); 382 388 FreePool (CleanFilePathStr); 383 389 return (SHELL_INVALID_PARAMETER); … … 387 393 HiiOutput = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_CP_OUTPUT), NULL); 388 394 HiiResultOk = HiiGetString (gShellLevel2HiiHandle, STRING_TOKEN (STR_GEN_RES_OK), NULL); 389 DestPath = AllocateZeroPool (PathSize);390 391 if ( DestPath == NULL || HiiOutput == NULL || HiiResultOk == NULL) {392 SHELL_FREE_NON_NULL (DestPath);393 SHELL_FREE_NON_NULL (HiiOutput);394 SHELL_FREE_NON_NULL (HiiResultOk);395 DestPath = AllocateZeroPool (PathSize); 396 397 if ((DestPath == NULL) || (HiiOutput == NULL) || (HiiResultOk == NULL)) { 398 SHELL_FREE_NON_NULL (DestPath); 399 SHELL_FREE_NON_NULL (HiiOutput); 400 SHELL_FREE_NON_NULL (HiiResultOk); 395 401 FreePool (CleanFilePathStr); 396 402 return (SHELL_OUT_OF_RESOURCES); … … 400 406 // Go through the list of files to copy... 401 407 // 402 for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode(&FileList->Link) 403 ; !IsNull(&FileList->Link, &Node->Link) 404 ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode(&FileList->Link, &Node->Link) 405 ){ 406 if (ShellGetExecutionBreakFlag()) { 408 for (Node = (EFI_SHELL_FILE_INFO *)GetFirstNode (&FileList->Link) 409 ; !IsNull (&FileList->Link, &Node->Link) 410 ; Node = (EFI_SHELL_FILE_INFO *)GetNextNode (&FileList->Link, &Node->Link) 411 ) 412 { 413 if (ShellGetExecutionBreakFlag ()) { 407 414 break; 408 415 } 409 ASSERT(Node->FileName != NULL); 410 ASSERT(Node->FullName != NULL); 416 417 ASSERT (Node->FileName != NULL); 418 ASSERT (Node->FullName != NULL); 411 419 412 420 // 413 421 // skip the directory traversing stuff... 414 422 // 415 if ( StrCmp(Node->FileName, L".") == 0 || StrCmp(Node->FileName, L"..") == 0) {423 if ((StrCmp (Node->FileName, L".") == 0) || (StrCmp (Node->FileName, L"..") == 0)) { 416 424 continue; 417 425 } 418 426 419 if (FileList->Link.ForwardLink == FileList->Link.BackLink // 1 item 420 && EFI_ERROR(ShellIsDirectory(CleanFilePathStr)) // not an existing directory 421 ) { 422 if (StrStr(CleanFilePathStr, L":") == NULL) { 427 if ( (FileList->Link.ForwardLink == FileList->Link.BackLink) // 1 item 428 && EFI_ERROR (ShellIsDirectory (CleanFilePathStr)) // not an existing directory 429 ) 430 { 431 if (StrStr (CleanFilePathStr, L":") == NULL) { 423 432 // 424 433 // simple copy of a single file 425 434 // 426 435 if (Cwd != NULL) { 427 StrCpyS (DestPath, PathSize / sizeof(CHAR16), Cwd);428 StrCatS (DestPath, PathSize / sizeof(CHAR16), L"\\");436 StrCpyS (DestPath, PathSize / sizeof (CHAR16), Cwd); 437 StrCatS (DestPath, PathSize / sizeof (CHAR16), L"\\"); 429 438 } else { 430 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);439 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); 431 440 FreePool (CleanFilePathStr); 432 441 return (SHELL_INVALID_PARAMETER); 433 442 } 434 if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') { 435 StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\"); 436 } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') { 437 ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; 438 } 439 StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); 443 444 if ((DestPath[StrLen (DestPath)-1] != L'\\') && (CleanFilePathStr[0] != L'\\')) { 445 StrCatS (DestPath, PathSize / sizeof (CHAR16), L"\\"); 446 } else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (CleanFilePathStr[0] == L'\\')) { 447 ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL; 448 } 449 450 StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr); 440 451 } else { 441 StrCpyS (DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr);452 StrCpyS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr); 442 453 } 443 454 } else { … … 450 461 // 451 462 if (CleanFilePathStr[0] == L'\\') { 452 453 454 463 // 464 // Copy to the root of CWD 465 // 455 466 if (Cwd != NULL) { 456 StrCpyS (DestPath, PathSize/sizeof(CHAR16), Cwd);457 StrCatS (DestPath, PathSize/sizeof(CHAR16), L"\\");467 StrCpyS (DestPath, PathSize/sizeof (CHAR16), Cwd); 468 StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\"); 458 469 } else { 459 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp",CleanFilePathStr);460 FreePool (CleanFilePathStr);470 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); 471 FreePool (CleanFilePathStr); 461 472 return (SHELL_INVALID_PARAMETER); 462 473 } 463 while (PathRemoveLastItem(DestPath)); 464 StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr+1); 465 StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); 466 } else if (StrStr(CleanFilePathStr, L":") == NULL) { 474 475 while (PathRemoveLastItem (DestPath)) { 476 } 477 478 StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr+1); 479 StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName); 480 } else if (StrStr (CleanFilePathStr, L":") == NULL) { 467 481 if (Cwd != NULL) { 468 StrCpyS (DestPath, PathSize/sizeof(CHAR16), Cwd);469 StrCatS (DestPath, PathSize/sizeof(CHAR16), L"\\");482 StrCpyS (DestPath, PathSize/sizeof (CHAR16), Cwd); 483 StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\"); 470 484 } else { 471 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr);472 FreePool (CleanFilePathStr);485 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); 486 FreePool (CleanFilePathStr); 473 487 return (SHELL_INVALID_PARAMETER); 474 488 } 475 if (DestPath[StrLen(DestPath)-1] != L'\\' && CleanFilePathStr[0] != L'\\') { 476 StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); 477 } else if (DestPath[StrLen(DestPath)-1] == L'\\' && CleanFilePathStr[0] == L'\\') { 478 ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; 479 } 480 StrCatS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); 481 if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') { 482 StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); 483 } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') { 484 ((CHAR16*)DestPath)[StrLen(DestPath)-1] = CHAR_NULL; 485 } 486 StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); 487 489 490 if ((DestPath[StrLen (DestPath)-1] != L'\\') && (CleanFilePathStr[0] != L'\\')) { 491 StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\"); 492 } else if ((DestPath[StrLen (DestPath)-1] == L'\\') && (CleanFilePathStr[0] == L'\\')) { 493 ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL; 494 } 495 496 StrCatS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr); 497 if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] != L'\\') && (Node->FileName[0] != L'\\')) { 498 StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\"); 499 } else if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] == L'\\') && (Node->FileName[0] == L'\\')) { 500 ((CHAR16 *)DestPath)[StrLen (DestPath)-1] = CHAR_NULL; 501 } 502 503 StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName); 488 504 } else { 489 StrCpyS(DestPath, PathSize/sizeof(CHAR16), CleanFilePathStr); 490 if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] != L'\\' && Node->FileName[0] != L'\\') { 491 StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\"); 492 } else if (CleanFilePathStr[StrLen(CleanFilePathStr)-1] == L'\\' && Node->FileName[0] == L'\\') { 493 ((CHAR16*)CleanFilePathStr)[StrLen(CleanFilePathStr)-1] = CHAR_NULL; 494 } 495 StrCatS(DestPath, PathSize/sizeof(CHAR16), Node->FileName); 505 StrCpyS (DestPath, PathSize/sizeof (CHAR16), CleanFilePathStr); 506 if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] != L'\\') && (Node->FileName[0] != L'\\')) { 507 StrCatS (DestPath, PathSize/sizeof (CHAR16), L"\\"); 508 } else if ((CleanFilePathStr[StrLen (CleanFilePathStr)-1] == L'\\') && (Node->FileName[0] == L'\\')) { 509 ((CHAR16 *)CleanFilePathStr)[StrLen (CleanFilePathStr)-1] = CHAR_NULL; 510 } 511 512 StrCatS (DestPath, PathSize/sizeof (CHAR16), Node->FileName); 496 513 } 497 514 } … … 500 517 // Make sure the path exists 501 518 // 502 if (EFI_ERROR (VerifyIntermediateDirectories(DestPath))) {503 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath);519 if (EFI_ERROR (VerifyIntermediateDirectories (DestPath))) { 520 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DIR_WNF), gShellLevel2HiiHandle, L"cp", DestPath); 504 521 ShellStatus = SHELL_DEVICE_ERROR; 505 522 break; 506 523 } 507 524 508 if ( !EFI_ERROR(ShellIsDirectory(Node->FullName)) 509 && !EFI_ERROR(ShellIsDirectory(DestPath)) 510 && StrniCmp(Node->FullName, DestPath, StrLen(DestPath)) == 0 511 ){ 512 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp"); 525 if ( !EFI_ERROR (ShellIsDirectory (Node->FullName)) 526 && !EFI_ERROR (ShellIsDirectory (DestPath)) 527 && (StrniCmp (Node->FullName, DestPath, StrLen (DestPath)) == 0) 528 ) 529 { 530 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_PARENT), gShellLevel2HiiHandle, L"cp"); 513 531 ShellStatus = SHELL_INVALID_PARAMETER; 514 532 break; 515 533 } 516 if (StringNoCaseCompare(&Node->FullName, &DestPath) == 0) { 517 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); 534 535 if (StringNoCaseCompare (&Node->FullName, &DestPath) == 0) { 536 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); 518 537 ShellStatus = SHELL_INVALID_PARAMETER; 519 538 break; 520 539 } 521 540 522 if ((StrniCmp(Node->FullName, DestPath, StrLen(Node->FullName)) == 0) 523 && (DestPath[StrLen(Node->FullName)] == CHAR_NULL || DestPath[StrLen(Node->FullName)] == L'\\') 524 ) { 525 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); 541 if ( (StrniCmp (Node->FullName, DestPath, StrLen (Node->FullName)) == 0) 542 && ((DestPath[StrLen (Node->FullName)] == CHAR_NULL) || (DestPath[StrLen (Node->FullName)] == L'\\')) 543 ) 544 { 545 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_SD_SAME), gShellLevel2HiiHandle, L"cp"); 526 546 ShellStatus = SHELL_INVALID_PARAMETER; 527 547 break; 528 548 } 529 549 530 PathCleanUpDirectories (DestPath);550 PathCleanUpDirectories (DestPath); 531 551 532 552 if (!SilentMode) { 533 ShellPrintEx (-1, -1, HiiOutput, Node->FullName, DestPath);553 ShellPrintEx (-1, -1, HiiOutput, Node->FullName, DestPath); 534 554 } 535 555 … … 537 557 // copy single file... 538 558 // 539 ShellStatus = CopySingleFile (Node->FullName, DestPath, &Response, SilentMode, L"cp");559 ShellStatus = CopySingleFile (Node->FullName, DestPath, &Response, SilentMode, L"cp"); 540 560 if (ShellStatus != SHELL_SUCCESS) { 541 561 break; 542 562 } 543 563 } 544 if (ShellStatus == SHELL_SUCCESS && Resp == NULL) { 545 ShellPrintEx(-1, -1, L"%s", HiiResultOk); 546 } 547 548 SHELL_FREE_NON_NULL(DestPath); 549 SHELL_FREE_NON_NULL(HiiOutput); 550 SHELL_FREE_NON_NULL(HiiResultOk); 551 SHELL_FREE_NON_NULL(CleanFilePathStr); 564 565 if ((ShellStatus == SHELL_SUCCESS) && (Resp == NULL)) { 566 ShellPrintEx (-1, -1, L"%s", HiiResultOk); 567 } 568 569 SHELL_FREE_NON_NULL (DestPath); 570 SHELL_FREE_NON_NULL (HiiOutput); 571 SHELL_FREE_NON_NULL (HiiResultOk); 572 SHELL_FREE_NON_NULL (CleanFilePathStr); 552 573 if (Resp == NULL) { 553 SHELL_FREE_NON_NULL (Response);574 SHELL_FREE_NON_NULL (Response); 554 575 } 555 576 556 577 return (ShellStatus); 557 558 578 } 559 579 … … 571 591 **/ 572 592 SHELL_STATUS 573 ProcessValidateAndCopyFiles (593 ProcessValidateAndCopyFiles ( 574 594 IN EFI_SHELL_FILE_INFO *FileList, 575 595 IN CONST CHAR16 *DestDir, … … 578 598 ) 579 599 { 580 SHELL_STATUS ShellStatus;581 EFI_SHELL_FILE_INFO *List;582 EFI_FILE_INFO *FileInfo;583 CHAR16 *FullName;584 585 List 586 FullName 587 FileInfo 588 589 ShellOpenFileMetaArg ((CHAR16*)DestDir, EFI_FILE_MODE_READ, &List);590 if ( List != NULL && List->Link.ForwardLink != List->Link.BackLink) {591 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"cp", DestDir);600 SHELL_STATUS ShellStatus; 601 EFI_SHELL_FILE_INFO *List; 602 EFI_FILE_INFO *FileInfo; 603 CHAR16 *FullName; 604 605 List = NULL; 606 FullName = NULL; 607 FileInfo = NULL; 608 609 ShellOpenFileMetaArg ((CHAR16 *)DestDir, EFI_FILE_MODE_READ, &List); 610 if ((List != NULL) && (List->Link.ForwardLink != List->Link.BackLink)) { 611 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_MARG_ERROR), gShellLevel2HiiHandle, L"cp", DestDir); 592 612 ShellStatus = SHELL_INVALID_PARAMETER; 593 ShellCloseFileMetaArg (&List);613 ShellCloseFileMetaArg (&List); 594 614 } else if (List != NULL) { 595 ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL);596 ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL);597 FileInfo = gEfiShellProtocol->GetFileInfo (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle);598 ASSERT (FileInfo != NULL);599 StrnCatGrow (&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0);600 ShellCloseFileMetaArg (&List);615 ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink) != NULL); 616 ASSERT (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName != NULL); 617 FileInfo = gEfiShellProtocol->GetFileInfo (((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->Handle); 618 ASSERT (FileInfo != NULL); 619 StrnCatGrow (&FullName, NULL, ((EFI_SHELL_FILE_INFO *)List->Link.ForwardLink)->FullName, 0); 620 ShellCloseFileMetaArg (&List); 601 621 if ((FileInfo->Attribute & EFI_FILE_READ_ONLY) == 0) { 602 ShellStatus = ValidateAndCopyFiles (FileList, FullName, SilentMode, RecursiveMode, NULL);622 ShellStatus = ValidateAndCopyFiles (FileList, FullName, SilentMode, RecursiveMode, NULL); 603 623 } else { 604 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_ERROR), gShellLevel2HiiHandle, L"cp");624 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CP_DEST_ERROR), gShellLevel2HiiHandle, L"cp"); 605 625 ShellStatus = SHELL_ACCESS_DENIED; 606 626 } 607 627 } else { 608 ShellCloseFileMetaArg (&List);609 ShellStatus = ValidateAndCopyFiles (FileList, DestDir, SilentMode, RecursiveMode, NULL);610 } 611 612 SHELL_FREE_NON_NULL (FileInfo);613 SHELL_FREE_NON_NULL (FullName);628 ShellCloseFileMetaArg (&List); 629 ShellStatus = ValidateAndCopyFiles (FileList, DestDir, SilentMode, RecursiveMode, NULL); 630 } 631 632 SHELL_FREE_NON_NULL (FileInfo); 633 SHELL_FREE_NON_NULL (FullName); 614 634 return (ShellStatus); 615 635 } 616 636 617 STATIC CONST SHELL_PARAM_ITEM ParamList[] = {618 { L"-r", TypeFlag},619 { L"-q", TypeFlag},620 { NULL, TypeMax}621 637 STATIC CONST SHELL_PARAM_ITEM ParamList[] = { 638 { L"-r", TypeFlag }, 639 { L"-q", TypeFlag }, 640 { NULL, TypeMax } 641 }; 622 642 623 643 /** … … 634 654 ) 635 655 { 636 EFI_STATUS Status;637 LIST_ENTRY *Package;638 CHAR16 *ProblemParam;639 SHELL_STATUS ShellStatus;640 UINTN ParamCount;641 UINTN LoopCounter;642 EFI_SHELL_FILE_INFO *FileList;643 BOOLEAN SilentMode;644 BOOLEAN RecursiveMode;645 CONST CHAR16 *Cwd;646 CHAR16 *FullCwd;647 648 ProblemParam 649 ShellStatus 650 ParamCount 651 FileList 656 EFI_STATUS Status; 657 LIST_ENTRY *Package; 658 CHAR16 *ProblemParam; 659 SHELL_STATUS ShellStatus; 660 UINTN ParamCount; 661 UINTN LoopCounter; 662 EFI_SHELL_FILE_INFO *FileList; 663 BOOLEAN SilentMode; 664 BOOLEAN RecursiveMode; 665 CONST CHAR16 *Cwd; 666 CHAR16 *FullCwd; 667 668 ProblemParam = NULL; 669 ShellStatus = SHELL_SUCCESS; 670 ParamCount = 0; 671 FileList = NULL; 652 672 653 673 // 654 674 // initialize the shell lib (we must be in non-auto-init...) 655 675 // 656 Status = ShellInitialize ();657 ASSERT_EFI_ERROR (Status);658 659 Status = CommandInit ();660 ASSERT_EFI_ERROR (Status);676 Status = ShellInitialize (); 677 ASSERT_EFI_ERROR (Status); 678 679 Status = CommandInit (); 680 ASSERT_EFI_ERROR (Status); 661 681 662 682 // … … 664 684 // 665 685 Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE); 666 if (EFI_ERROR (Status)) {667 if ( Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {668 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam);669 FreePool (ProblemParam);686 if (EFI_ERROR (Status)) { 687 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) { 688 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cp", ProblemParam); 689 FreePool (ProblemParam); 670 690 ShellStatus = SHELL_INVALID_PARAMETER; 671 691 } else { 672 ASSERT (FALSE);692 ASSERT (FALSE); 673 693 } 674 694 } else { … … 676 696 // check for "-?" 677 697 // 678 if (ShellCommandLineGetFlag (Package, L"-?")) {679 ASSERT (FALSE);698 if (ShellCommandLineGetFlag (Package, L"-?")) { 699 ASSERT (FALSE); 680 700 } 681 701 … … 683 703 // Initialize SilentMode and RecursiveMode 684 704 // 685 if (gEfiShellProtocol->BatchIsActive ()) {705 if (gEfiShellProtocol->BatchIsActive ()) { 686 706 SilentMode = TRUE; 687 707 } else { 688 SilentMode = ShellCommandLineGetFlag(Package, L"-q"); 689 } 690 RecursiveMode = ShellCommandLineGetFlag(Package, L"-r"); 691 692 switch (ParamCount = ShellCommandLineGetCount(Package)) { 708 SilentMode = ShellCommandLineGetFlag (Package, L"-q"); 709 } 710 711 RecursiveMode = ShellCommandLineGetFlag (Package, L"-r"); 712 713 switch (ParamCount = ShellCommandLineGetCount (Package)) { 693 714 case 0: 694 715 case 1: … … 696 717 // we have insufficient parameters 697 718 // 698 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp");719 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel2HiiHandle, L"cp"); 699 720 ShellStatus = SHELL_INVALID_PARAMETER; 700 721 break; … … 703 724 // must have valid CWD for single parameter... 704 725 // 705 Cwd = ShellGetCurrentDir (NULL);706 if (Cwd == NULL) {707 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp");726 Cwd = ShellGetCurrentDir (NULL); 727 if (Cwd == NULL) { 728 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cp"); 708 729 ShellStatus = SHELL_INVALID_PARAMETER; 709 730 } else { 710 Status = ShellOpenFileMetaArg ((CHAR16*)ShellCommandLineGetRawValue(Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList);711 if ( FileList == NULL || IsListEmpty(&FileList->Link) || EFI_ERROR(Status)) {712 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1));731 Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, 1), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); 732 if ((FileList == NULL) || IsListEmpty (&FileList->Link) || EFI_ERROR (Status)) { 733 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, 1)); 713 734 ShellStatus = SHELL_NOT_FOUND; 714 } else 715 FullCwd = AllocateZeroPool (StrSize(Cwd) + sizeof(CHAR16));735 } else { 736 FullCwd = AllocateZeroPool (StrSize (Cwd) + sizeof (CHAR16)); 716 737 if (FullCwd == NULL) { 717 738 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_OUT_MEM), gShellLevel2HiiHandle, L"cp"); … … 730 751 // Make a big list of all the files... 731 752 // 732 for (ParamCount--, LoopCounter = 1 ; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS; LoopCounter++) {733 if (ShellGetExecutionBreakFlag ()) {753 for (ParamCount--, LoopCounter = 1; LoopCounter < ParamCount && ShellStatus == SHELL_SUCCESS; LoopCounter++) { 754 if (ShellGetExecutionBreakFlag ()) { 734 755 break; 735 756 } 736 Status = ShellOpenFileMetaArg((CHAR16*)ShellCommandLineGetRawValue(Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); 737 if (EFI_ERROR(Status) || FileList == NULL || IsListEmpty(&FileList->Link)) { 738 ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, LoopCounter)); 757 758 Status = ShellOpenFileMetaArg ((CHAR16 *)ShellCommandLineGetRawValue (Package, LoopCounter), EFI_FILE_MODE_WRITE|EFI_FILE_MODE_READ, &FileList); 759 if (EFI_ERROR (Status) || (FileList == NULL) || IsListEmpty (&FileList->Link)) { 760 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, LoopCounter)); 739 761 ShellStatus = SHELL_NOT_FOUND; 740 762 } 741 763 } 764 742 765 if (ShellStatus != SHELL_SUCCESS) { 743 Status = ShellCloseFileMetaArg (&FileList);766 Status = ShellCloseFileMetaArg (&FileList); 744 767 } else { 745 768 // 746 769 // now copy them all... 747 770 // 748 if ( FileList != NULL && !IsListEmpty(&FileList->Link)) {749 ShellStatus = ProcessValidateAndCopyFiles (FileList, PathCleanUpDirectories((CHAR16*)ShellCommandLineGetRawValue(Package, ParamCount)), SilentMode, RecursiveMode);750 Status = ShellCloseFileMetaArg(&FileList);751 if (EFI_ERROR (Status) && ShellStatus == SHELL_SUCCESS) {752 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, ParamCount), ShellStatus|MAX_BIT);771 if ((FileList != NULL) && !IsListEmpty (&FileList->Link)) { 772 ShellStatus = ProcessValidateAndCopyFiles (FileList, PathCleanUpDirectories ((CHAR16 *)ShellCommandLineGetRawValue (Package, ParamCount)), SilentMode, RecursiveMode); 773 Status = ShellCloseFileMetaArg (&FileList); 774 if (EFI_ERROR (Status) && (ShellStatus == SHELL_SUCCESS)) { 775 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_ERR_FILE), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue (Package, ParamCount), ShellStatus|MAX_BIT); 753 776 ShellStatus = SHELL_ACCESS_DENIED; 754 777 } 755 778 } 756 779 } 780 757 781 break; 758 782 } // switch on parameter count 759 783 760 784 if (FileList != NULL) { 761 ShellCloseFileMetaArg (&FileList);785 ShellCloseFileMetaArg (&FileList); 762 786 } 763 787 … … 768 792 } 769 793 770 if (ShellGetExecutionBreakFlag ()) {794 if (ShellGetExecutionBreakFlag ()) { 771 795 return (SHELL_ABORTED); 772 796 } … … 774 798 return (ShellStatus); 775 799 } 776
Note:
See TracChangeset
for help on using the changeset viewer.