From c7916981cc01e37d189e1802463fa68d10a17bf2 Mon Sep 17 00:00:00 2001 From: xgu3 Date: Fri, 26 Jan 2007 08:35:57 +0000 Subject: To fix, cd ...... works unnormally in shell USB CBI1 driver has no component name protocol git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2328 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/SimpleFileSystem/WinNtSimpleFileSystem.c | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'EdkNt32Pkg/Dxe/WinNtThunk') diff --git a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c index bea7de40f8..30f5476d5a 100644 --- a/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c +++ b/EdkNt32Pkg/Dxe/WinNtThunk/Bus/SimpleFileSystem/WinNtSimpleFileSystem.c @@ -688,6 +688,32 @@ OpenRoot: FileName[StrLen (FileName) - 1] = 0; } + // + // If file name does not equal to "." or "..", + // then we trim the leading/trailing blanks and trailing dots + // + if (StrCmp (FileName, L".") != 0 && StrCmp (FileName, L"..") != 0) { + // + // Trim leading blanks + // + Count = 0; + for (TempFileName = FileName; + *TempFileName != 0 && *TempFileName == L' '; + TempFileName++) { + Count++; + } + CutPrefix (FileName, Count); + // + // Trim trailing dots and blanks + // + for (TempFileName = FileName + StrLen (FileName) - 1; + TempFileName >= FileName && (*TempFileName == L' ' || *TempFileName == L'.'); + TempFileName--) { + ; + } + *(TempFileName + 1) = 0; + } + // // Attempt to open the file // @@ -738,8 +764,13 @@ OpenRoot: StrCat (NewPrivateFile->FileName, FileName + 1); } else { StrCpy (NewPrivateFile->FileName, NewPrivateFile->FilePath); - StrCat (NewPrivateFile->FileName, L"\\"); - StrCat (NewPrivateFile->FileName, FileName); + if (StrCmp (FileName, L"") != 0) { + // + // In case the filename becomes empty, especially after trimming dots and blanks + // + StrCat (NewPrivateFile->FileName, L"\\"); + StrCat (NewPrivateFile->FileName, FileName); + } } // -- cgit v1.2.3