From nobody Mon Apr 29 23:05:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1502862183932983.1803940605558; Tue, 15 Aug 2017 22:43:03 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E03B921E2DA7E; Tue, 15 Aug 2017 22:40:33 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8249921E2DA64 for ; Tue, 15 Aug 2017 22:40:32 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 15 Aug 2017 22:42:58 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.2]) by orsmga001.jf.intel.com with ESMTP; 15 Aug 2017 22:42:57 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,381,1498546800"; d="scan'208";a="1163082633" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 16 Aug 2017 13:42:53 +0800 Message-Id: <20170816054254.16184-2-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170816054254.16184-1-ruiyu.ni@intel.com> References: <20170816054254.16184-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 1/2] Shell/mkdir: Modify the help content to align to spec. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huajing Li MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Huajing Li Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- .../UefiShellLevel2CommandsLib.uni | 15 ++++++-----= ---- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Com= mandsLib.uni b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2C= ommandsLib.uni index 60f48f4633..f9c647a035 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLi= b.uni +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLi= b.uni @@ -464,18 +464,15 @@ "MKDIR dir [dir...]\r\n" ".SH OPTIONS\r\n" " \r\n" -" dir - Specifies the name of a directory or directories to create. (Wild= cards are not\r\n" -" allowed) \r\n" +" dir - Specifies the name of a directory or directories to create.\r\n" +" (Wildcards are not allowed)\r\n" ".SH DESCRIPTION\r\n" " \r\n" "NOTES:\r\n" -" 1. The parent directory must already exist.\r\n" -" 2. If the directory already exists, mkdir will abort.\r\n" -" 3. Specifying additional directory parameters dependent on previous\r\n" -" directory parameters is not allowed:\r\n" -" For example, mkdir new new\Test is not allowed.\r\n" -" 4. Redirecting output to a file that exists under the directory specifi= ed\r\n" -" by this command is not allowed.\r\n" +" 1. Mkdir can create one or more new directories.\r\n" +" 2. If dir includes nested directories, then parent directories will be\= r\n" +" created before child directories.\r\n" +" 3. If the directory already exists, mkdir will exit with an error.\r\n" ".SH EXAMPLES\r\n" " \r\n" "EXAMPLES:\r\n" --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel From nobody Mon Apr 29 23:05:30 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1502862186276920.1391964373707; Tue, 15 Aug 2017 22:43:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 25D9E21E2DA7D; Tue, 15 Aug 2017 22:40:36 -0700 (PDT) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 84E4121E2DA64 for ; Tue, 15 Aug 2017 22:40:33 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 15 Aug 2017 22:42:59 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.2]) by orsmga001.jf.intel.com with ESMTP; 15 Aug 2017 22:42:58 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,381,1498546800"; d="scan'208";a="1163082639" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Wed, 16 Aug 2017 13:42:54 +0800 Message-Id: <20170816054254.16184-3-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 In-Reply-To: <20170816054254.16184-1-ruiyu.ni@intel.com> References: <20170816054254.16184-1-ruiyu.ni@intel.com> Subject: [edk2] [PATCH 2/2] ShellPkg/mkdir: support creating nested directories X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huajing Li MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Huajing Li Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- .../Library/UefiShellLevel2CommandsLib/MkDir.c | 54 ++++++++++++++++++= ---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c b/ShellPkg= /Library/UefiShellLevel2CommandsLib/MkDir.c index 4aade13aac..3a9e037d0e 100644 --- a/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c +++ b/ShellPkg/Library/UefiShellLevel2CommandsLib/MkDir.c @@ -30,14 +30,19 @@ ShellCommandRunMkDir ( { EFI_STATUS Status; CONST CHAR16 *NewDirName; + CHAR16 *NewDirNameCopy; + CHAR16 *SplitName; + CHAR16 SaveSplitChar; UINTN DirCreateCount; LIST_ENTRY *Package; CHAR16 *ProblemParam; SHELL_FILE_HANDLE FileHandle; SHELL_STATUS ShellStatus; =20 - ShellStatus =3D SHELL_SUCCESS; - + ShellStatus =3D SHELL_SUCCESS; + NewDirNameCopy =3D NULL; + SplitName =3D NULL; + SaveSplitChar =3D CHAR_NULL; // // initialize the shell lib (we must be in non-auto-init...) // @@ -99,21 +104,54 @@ ShellCommandRunMkDir ( ShellCloseFile(&FileHandle); ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_ALREADY), = gShellLevel2HiiHandle, NewDirName); ShellStatus =3D SHELL_INVALID_PARAMETER; - break; } else { ASSERT(FileHandle =3D=3D NULL); // - // create the directory named NewDirName + // create the nested directory from parent to child. + // if NewDirName =3D test1\test2\test3, first create "test1\" di= rectory, then "test1\test2\", finally "test1\test2\test3".=20 // - Status =3D ShellCreateDirectory(NewDirName, &FileHandle); - if (FileHandle !=3D NULL) { - gEfiShellProtocol->CloseFile(FileHandle); + NewDirNameCopy =3D AllocateCopyPool (StrSize(NewDirName), NewDir= Name); + NewDirNameCopy =3D PathCleanUpDirectories (NewDirNameCopy); + if(NewDirNameCopy =3D=3D NULL) { + ShellStatus =3D SHELL_OUT_OF_RESOURCES; + break; + } + SplitName =3D NewDirNameCopy; + while (SplitName !=3D NULL) { + SplitName =3D StrStr (SplitName + 1, L"\\"); + if (SplitName !=3D NULL) { + SaveSplitChar =3D *(SplitName + 1); + *(SplitName + 1) =3D '\0'; + } + // + // check if current nested directory already exists... continu= e to create the child directory. + // + Status =3D ShellOpenFileByName (NewDirNameCopy, + &FileHandle, + EFI_FILE_MODE_READ, + EFI_FILE_DIRECTORY + ); + if (!EFI_ERROR(Status)) { + ShellCloseFile (&FileHandle); + } else { + Status =3D ShellCreateDirectory (NewDirNameCopy, &FileHandle= ); + if (EFI_ERROR(Status)) { + break; + } + if (FileHandle !=3D NULL) { + gEfiShellProtocol->CloseFile (FileHandle); + } + } + if (SplitName !=3D NULL) { + *(SplitName + 1) =3D SaveSplitChar; + } } if (EFI_ERROR(Status)) { - ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_MKDIR_CREATEFA= IL), gShellLevel2HiiHandle, NewDirName); + ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_MKDIR_CREATEF= AIL), gShellLevel2HiiHandle, NewDirName); ShellStatus =3D SHELL_ACCESS_DENIED; break; } + SHELL_FREE_NON_NULL (NewDirNameCopy); } } } --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel