Cwd = ShellInfoObject.NewEfiShellProtocol->GetCurDir(NULL);\r
if (Cwd != NULL) {\r
StrnCpyS(TabStr, (*BufferSize)/sizeof(CHAR16), Cwd, (*BufferSize)/sizeof(CHAR16) - 1);\r
+ StrCatS(TabStr, (*BufferSize)/sizeof(CHAR16), L"\\");\r
if (TabStr[StrLen(TabStr)-1] == L'\\' && *(CurrentString + TabPos) == L'\\' ) {\r
TabStr[StrLen(TabStr)-1] = CHAR_NULL;\r
}\r
if (Cwd == NULL) {\r
return (NULL);\r
}\r
- Size = StrSize(Cwd) + StrSize(Path) - sizeof(CHAR16);\r
+ Size = StrSize(Cwd) + StrSize(Path);\r
NewPath = AllocateZeroPool(Size);\r
if (NewPath == NULL) {\r
return (NULL);\r
}\r
StrCpyS(NewPath, Size/sizeof(CHAR16), Cwd);\r
+ StrCatS(NewPath, Size/sizeof(CHAR16), L"\\");\r
if (*Path == L'\\') {\r
Path++;\r
while (PathRemoveLastItem(NewPath)) ;\r
CurDir = EfiShellGetCurDir(NULL);\r
ASSERT((Path2 == NULL && Path2Size == 0) || (Path2 != NULL));\r
StrnCatGrow(&Path2, &Path2Size, CurDir, 0);\r
+ StrnCatGrow(&Path2, &Path2Size, L"\\", 0);\r
if (*Path == L'\\') {\r
Path++;\r
while (PathRemoveLastItem(Path2)) ;\r
FileSystemMapping is not NULL, it returns the current directory associated with the\r
FileSystemMapping. In both cases, the returned name includes the file system\r
mapping (i.e. fs0:\current-dir).\r
+ \r
+ Note that the current directory string should exclude the tailing backslash character.\r
\r
@param FileSystemMapping A pointer to the file system mapping. If NULL,\r
then the current working directory is returned.\r
If the current working directory or the current working file system is changed then the\r
%cwd% environment variable will be updated\r
\r
+ Note that the current directory string should exclude the tailing backslash character.\r
+\r
@param FileSystem A pointer to the file system's mapped name. If NULL, then the current working\r
directory is changed.\r
@param Dir Points to the NULL-terminated directory on the device specified by FileSystem.\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);\r
}\r
- if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {\r
+ if ((MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') || (MapListItem->CurrentDirectoryPath == NULL)) {\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
+ if (MapListItem->CurrentDirectoryPath != NULL) {\r
+ MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;\r
+ }\r
}\r
} else {\r
//\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, DirectoryName, 0);\r
- if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] != L'\\') {\r
+ if (MapListItem->CurrentDirectoryPath != NULL && MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] == L'\\') {\r
ASSERT((MapListItem->CurrentDirectoryPath == NULL && Size == 0) || (MapListItem->CurrentDirectoryPath != NULL));\r
- MapListItem->CurrentDirectoryPath = StrnCatGrow(&MapListItem->CurrentDirectoryPath, &Size, L"\\", 0);\r
+ MapListItem->CurrentDirectoryPath[StrLen(MapListItem->CurrentDirectoryPath)-1] = CHAR_NULL;\r
}\r
}\r
}\r
/** @file\r
Provides interface to shell functionality for shell commands and applications.\r
\r
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
name. If the DeviceName is not NULL, it returns the current directory name\r
on specified drive.\r
\r
+ Note that the current directory string should exclude the tailing backslash character.\r
+\r
@param[in] DeviceName The name of the file system to get directory on.\r
\r
@retval NULL The directory does not exist.\r
EFI Shell protocol as defined in the UEFI Shell 2.0 specification including errata.\r
\r
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
FileSystemMapping. In both cases, the returned name includes the file system\r
mapping (i.e. fs0:\current-dir).\r
\r
+ Note that the current directory string should exclude the tailing backslash character.\r
+\r
@param[in] FileSystemMapping A pointer to the file system mapping. If NULL,\r
then the current working directory is returned.\r
\r
Main file for attrib shell level 2 function.\r
\r
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
EFI_STATUS Status;\r
LIST_ENTRY *Package;\r
CONST CHAR16 *Directory;\r
+ CHAR16 *Cwd;\r
CHAR16 *Path;\r
CHAR16 *Drive;\r
+ UINTN CwdSize;\r
UINTN DriveSize;\r
CHAR16 *ProblemParam;\r
SHELL_STATUS ShellStatus;\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd"); \r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
- Drive = GetFullyQualifiedPath(Directory);\r
+ CwdSize = StrSize(Directory) + sizeof(CHAR16);\r
+ Cwd = AllocateZeroPool(CwdSize);\r
+ ASSERT(Cwd!=NULL);\r
+ StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);\r
+ StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");\r
+ Drive = GetFullyQualifiedPath(Cwd);\r
PathRemoveLastItem(Drive);\r
+ FreePool(Cwd);\r
}\r
if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
//\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd"); \r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
- Drive = GetFullyQualifiedPath(Directory);\r
- while (PathRemoveLastItem(Drive)) ;\r
+ CwdSize = StrSize(Directory) + sizeof(CHAR16);\r
+ Cwd = AllocateZeroPool(CwdSize);\r
+ ASSERT(Cwd!=NULL);\r
+ StrCpyS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, Directory);\r
+ StrCatS(Cwd, StrSize(Directory)/sizeof(CHAR16)+1, L"\\");\r
+ Drive = GetFullyQualifiedPath(Cwd);\r
+ while (PathRemoveLastItem(Drive));\r
+ FreePool(Cwd);\r
}\r
if (ShellStatus == SHELL_SUCCESS && Drive != NULL) {\r
//\r
} else {\r
ASSERT((Drive == NULL && DriveSize == 0) || (Drive != NULL));\r
Drive = StrnCatGrow(&Drive, &DriveSize, ShellGetCurrentDir(NULL), 0);\r
+ Drive = StrnCatGrow(&Drive, &DriveSize, L"\\", 0);\r
if (*Param1Copy == L'\\') {\r
while (PathRemoveLastItem(Drive)) ;\r
Drive = StrnCatGrow(&Drive, &DriveSize, Param1Copy+1, 0);\r
\r
NewSize = StrSize(CleanFilePathStr);\r
NewSize += StrSize(Node->FullName);\r
- NewSize += (Cwd == NULL)? 0 : StrSize(Cwd);\r
+ NewSize += (Cwd == NULL)? 0 : (StrSize(Cwd) + sizeof(CHAR16));\r
if (NewSize > PathSize) {\r
PathSize = NewSize;\r
}\r
//\r
if (Cwd != NULL) {\r
StrCpyS(DestPath, PathSize / sizeof(CHAR16), Cwd);\r
+ StrCatS(DestPath, PathSize / sizeof(CHAR16), L"\\");\r
} else {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); \r
FreePool (CleanFilePathStr);\r
//\r
if (Cwd != NULL) {\r
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);\r
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");\r
} else {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); \r
FreePool(CleanFilePathStr);\r
} else if (StrStr(CleanFilePathStr, L":") == NULL) {\r
if (Cwd != NULL) {\r
StrCpyS(DestPath, PathSize/sizeof(CHAR16), Cwd);\r
+ StrCatS(DestPath, PathSize/sizeof(CHAR16), L"\\");\r
} else {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cp", CleanFilePathStr); \r
FreePool(CleanFilePathStr);\r
BOOLEAN SilentMode;\r
BOOLEAN RecursiveMode;\r
CONST CHAR16 *Cwd;\r
+ CHAR16 *FullCwd;\r
\r
ProblemParam = NULL;\r
ShellStatus = SHELL_SUCCESS;\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel2HiiHandle, L"cp", ShellCommandLineGetRawValue(Package, 1)); \r
ShellStatus = SHELL_NOT_FOUND;\r
} else {\r
- ShellStatus = ProcessValidateAndCopyFiles(FileList, Cwd, SilentMode, RecursiveMode);\r
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
+ ASSERT (FullCwd != NULL);\r
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
+ ShellStatus = ProcessValidateAndCopyFiles(FileList, FullCwd, SilentMode, RecursiveMode);\r
+ FreePool(FullCwd);\r
}\r
}\r
\r
Main file for ls shell level 2 function.\r
\r
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.<BR>\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
ASSERT(FullPath == NULL);\r
StrnCatGrow(&SearchString, NULL, L"*", 0);\r
StrnCatGrow(&FullPath, NULL, CurDir, 0);\r
+ Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
} else {\r
if (StrStr(PathName, L":") == NULL && gEfiShellProtocol->GetCurDir(NULL) == NULL) {\r
//\r
ShellCommandLineFreeVarList (Package);\r
return SHELL_OUT_OF_RESOURCES;\r
}\r
+ Size = FullPath != NULL? StrSize(FullPath) : 0;\r
+ StrnCatGrow(&FullPath, &Size, L"\\", 0);\r
}\r
StrnCatGrow(&FullPath, &Size, PathName, 0);\r
if (FullPath == NULL) {\r
CHAR16 *DestPath;\r
CHAR16 *FullDestPath;\r
CONST CHAR16 *Cwd;\r
+ CHAR16 *FullCwd;\r
SHELL_STATUS ShellStatus;\r
EFI_SHELL_FILE_INFO *Node;\r
VOID *Response;\r
Attr = 0;\r
CleanFilePathStr = NULL;\r
\r
+ FullCwd = AllocateZeroPool(StrSize(Cwd) + sizeof(CHAR16));\r
+ if (FullCwd == NULL) {\r
+ return SHELL_OUT_OF_RESOURCES;\r
+ } else {\r
+ StrCpyS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, Cwd);\r
+ StrCatS(FullCwd, StrSize(Cwd)/sizeof(CHAR16)+1, L"\\");\r
+ }\r
+\r
Status = ShellLevel2StripQuotes (DestParameter, &CleanFilePathStr);\r
if (EFI_ERROR (Status)) {\r
+ FreePool (FullCwd);\r
if (Status == EFI_OUT_OF_RESOURCES) {\r
return SHELL_OUT_OF_RESOURCES;\r
} else {\r
//\r
// Get and validate the destination location\r
//\r
- ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, Cwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
+ ShellStatus = GetDestinationLocation(CleanFilePathStr, &DestPath, FullCwd, (BOOLEAN)(FileList->Link.ForwardLink == FileList->Link.BackLink), &Attr);\r
FreePool (CleanFilePathStr);\r
\r
if (ShellStatus != SHELL_SUCCESS) {\r
+ FreePool (FullCwd);\r
return (ShellStatus);\r
}\r
DestPath = PathCleanUpDirectories(DestPath);\r
if (DestPath == NULL) {\r
+ FreePool (FullCwd);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
SHELL_FREE_NON_NULL(DestPath);\r
SHELL_FREE_NON_NULL(HiiOutput);\r
SHELL_FREE_NON_NULL(HiiResultOk);\r
+ FreePool (FullCwd);\r
return (SHELL_OUT_OF_RESOURCES);\r
}\r
\r
//\r
// Validate that the move is valid\r
//\r
- if (!IsValidMove(Node->FullName, Cwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
+ if (!IsValidMove(Node->FullName, FullCwd, FullDestPath!=NULL? FullDestPath:DestPath, Node->Info->Attribute, Attr, Node->Status)) {\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
continue;\r
}\r
//\r
// indicate to stop everything\r
//\r
+ FreePool(FullCwd);\r
return (SHELL_ABORTED);\r
case ShellPromptResponseAll:\r
*Resp = Response;\r
break;\r
default:\r
FreePool(Response);\r
+ FreePool(FullCwd);\r
return SHELL_ABORTED;\r
}\r
Status = ShellDeleteFileByName(FullDestPath!=NULL? FullDestPath:DestPath);\r
}\r
\r
- if (IsBetweenFileSystem(Node->FullName, Cwd, DestPath)) {\r
+ if (IsBetweenFileSystem(Node->FullName, FullCwd, DestPath)) {\r
while (FullDestPath == NULL && DestPath != NULL && DestPath[0] != CHAR_NULL && DestPath[StrLen(DestPath) - 1] == L'\\') {\r
DestPath[StrLen(DestPath) - 1] = CHAR_NULL;\r
}\r
SHELL_FREE_NON_NULL(DestPath);\r
SHELL_FREE_NON_NULL(HiiOutput);\r
SHELL_FREE_NON_NULL(HiiResultOk);\r
+ FreePool (FullCwd);\r
return (ShellStatus);\r
}\r
\r
EFI_STATUS Status;\r
LIST_ENTRY *Package;\r
CHAR16 *ProblemParam;\r
+ CHAR16 *Cwd;\r
+ UINTN CwdSize;\r
SHELL_STATUS ShellStatus;\r
UINTN ParamCount;\r
UINTN LoopCounter;\r
//\r
// ValidateAndMoveFiles will report errors to the screen itself\r
//\r
- ShellStatus = ValidateAndMoveFiles(FileList, &Response, ShellGetCurrentDir(NULL));\r
+ CwdSize = StrSize(ShellGetCurrentDir(NULL)) + 1;\r
+ Cwd = AllocateZeroPool(CwdSize);\r
+ ASSERT (Cwd != NULL);\r
+ StrCpyS(Cwd, CwdSize/sizeof(CHAR16), ShellGetCurrentDir(NULL));\r
+ StrCatS(Cwd, CwdSize/sizeof(CHAR16), L"\\");\r
+ ShellStatus = ValidateAndMoveFiles(FileList, &Response, Cwd);\r
+ FreePool(Cwd);\r
}\r
}\r
\r
Pattern = NULL;\r
SearchString = NULL;\r
Size = 0;\r
- Pattern = StrnCatGrow(&Pattern , NULL, TempLocation , 0);\r
+ Pattern = StrnCatGrow(&Pattern, &Size, TempLocation , 0);\r
+ Pattern = StrnCatGrow(&Pattern, &Size, L"\\" , 0);\r
+ Size = 0;\r
SearchString = StrnCatGrow(&SearchString, &Size, Node->FullName, 0);\r
if (!EFI_ERROR(ShellIsDirectory(SearchString))) {\r
SearchString = StrnCatGrow(&SearchString, &Size, L"\\", 0);\r
* functions are non-interactive only\r
\r
Copyright (c) 2014 Hewlett-Packard Development Company, L.P.\r
- Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
if (StrStr(Path, L":") == NULL) {\r
CurDir = gEfiShellProtocol->GetCurDir(NULL);\r
StrnCatGrow(&PathToReturn, &Size, CurDir, 0);\r
+ StrnCatGrow(&PathToReturn, &Size, L"\\", 0);\r
if (*Path == L'\\') {\r
Path++;\r
}\r
name. If the DeviceName is not NULL, it returns the current directory name\r
on specified drive.\r
\r
+ Note that the current directory string should exclude the tailing backslash character.\r
+\r
@param DeviceName the name of the drive to get directory on\r
\r
@retval NULL the directory does not exist\r
\r
Path = ShellGetEnvironmentVariable(L"cwd");\r
if (Path != NULL) {\r
- Size = StrSize(Path);\r
+ Size = StrSize(Path) + sizeof(CHAR16);\r
Size += StrSize(FileName);\r
TestPath = AllocateZeroPool(Size);\r
if (TestPath == NULL) {\r
return (NULL);\r
}\r
StrCpyS(TestPath, Size/sizeof(CHAR16), Path);\r
+ StrCatS(TestPath, Size/sizeof(CHAR16), L"\\");\r
StrCatS(TestPath, Size/sizeof(CHAR16), FileName);\r
Status = ShellOpenFileByName(TestPath, &Handle, EFI_FILE_MODE_READ, 0);\r
if (!EFI_ERROR(Status)){\r