return (FALSE);\r
}\r
\r
+/**\r
+ function to determine if SrcPath is valid to mv.\r
+\r
+ if SrcPath equal CWD then it's invalid.\r
+ if SrcPath is the parent path of CWD then it's invalid.\r
+ is SrcPath is NULL return FALSE.\r
+\r
+ if CwdPath is NULL then ASSERT()\r
+\r
+ @param SrcPath [in] The source path.\r
+ @param CwdPath [in] The current working directory.\r
+\r
+ @retval TRUE The source path is valid.\r
+ @retval FALSE The source path is invalid.\r
+**/\r
+BOOLEAN\r
+IsSoucePathValid(\r
+ IN CONST CHAR16* SrcPath,\r
+ IN CONST CHAR16* CwdPath\r
+ )\r
+{\r
+ CHAR16* SrcPathBuffer;\r
+ CHAR16* CwdPathBuffer;\r
+ BOOLEAN Ret;\r
+\r
+ ASSERT (CwdPath != NULL);\r
+ if (SrcPath == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ Ret = TRUE;\r
+\r
+ SrcPathBuffer = AllocateCopyPool (StrSize (SrcPath), SrcPath);\r
+ if (SrcPathBuffer == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ CwdPathBuffer = AllocateCopyPool (StrSize (CwdPath), CwdPath);\r
+ if (CwdPathBuffer == NULL) {\r
+ FreePool(SrcPathBuffer);\r
+ return FALSE;\r
+ }\r
+\r
+ gUnicodeCollation->StrUpr (gUnicodeCollation, SrcPathBuffer);\r
+ gUnicodeCollation->StrUpr (gUnicodeCollation, CwdPathBuffer);\r
+\r
+ if (SrcPathBuffer[StrLen (SrcPathBuffer) -1 ] == L'\\') {\r
+ SrcPathBuffer[StrLen (SrcPathBuffer) - 1] = CHAR_NULL;\r
+ }\r
+\r
+ if (CwdPathBuffer[StrLen (CwdPathBuffer) - 1] == L'\\') {\r
+ CwdPathBuffer[StrLen (CwdPathBuffer) - 1] = CHAR_NULL;\r
+ }\r
+\r
+ if (StrCmp (CwdPathBuffer, SrcPathBuffer) == 0 ||\r
+ ((StrStr (CwdPathBuffer, SrcPathBuffer) == CwdPathBuffer) &&\r
+ (CwdPathBuffer[StrLen (SrcPathBuffer)] == L'\\'))\r
+ ) {\r
+ Ret = FALSE;\r
+ }\r
+\r
+ FreePool (SrcPathBuffer);\r
+ FreePool (CwdPathBuffer);\r
+\r
+ return Ret;\r
+}\r
+\r
/**\r
Function to validate that moving a specific file (FileName) to a specific\r
location (DestPath) is valid.\r
CHAR16 *DestPathCopy;\r
CHAR16 *DestPathWalker;\r
\r
- if (Cwd != NULL && StrCmp(SourcePath, Cwd) == 0) {\r
- //\r
- // Invalid move\r
- //\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MV_INV_CWD), gShellLevel2HiiHandle);\r
- return (FALSE);\r
+ if ((Cwd != NULL) && ((Attribute & EFI_FILE_DIRECTORY) == EFI_FILE_DIRECTORY)) {\r
+ if (!IsSoucePathValid (SourcePath, Cwd)) {\r
+ //\r
+ // Invalid move\r
+ //\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_MV_INV_CWD), gShellLevel2HiiHandle);\r
+ return FALSE;\r
+ }\r
}\r
\r
//\r