/* Note that the current directory string should exclude the tailing backslash character. */
CONST CHAR16* EFIAPI EfiShellGetCurDir(IN CONST CHAR16 *FileSystemMapping OPTIONAL)
/* Note that the current directory string should exclude the tailing backslash character. */
CONST CHAR16* EFIAPI EfiShellGetCurDir(IN CONST CHAR16 *FileSystemMapping OPTIONAL)
{
  CHAR16          *PathToReturn;
  UINTN           Size;
  SHELL_MAP_LIST  *MapListItem;
  if (!IsListEmpty (&gShellMapList.Link)) {
    if (FileSystemMapping == NULL) {
      return (EfiShellGetEnv (L"cwd"));
    } else {
      Size         = 0;
      PathToReturn = NULL;
      MapListItem  = ShellCommandFindMapItem (FileSystemMapping);
      if (MapListItem != NULL) {
        ASSERT ((PathToReturn == NULL && Size == 0) || (PathToReturn != NULL));
        PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->MapName, 0);
        PathToReturn = StrnCatGrow (&PathToReturn, &Size, MapListItem->CurrentDirectoryPath, 0);
      }
    }
    return (AddBufferToFreeList (PathToReturn));
  } else {
    return (NULL);
  }
}