/** @file\r
Main file for Touch shell level 3 function.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved. <BR>\r
+ (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r
+ Copyright (c) 2009 - 2011, 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
\r
#include <Library/ShellLib.h>\r
\r
+/**\r
+ Do the touch operation on a single handle.\r
+\r
+ @param[in] Handle The handle to update the date/time on.\r
+\r
+ @retval EFI_ACCESS_DENIED The file referenced by Handle is read only.\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
TouchFileByHandle (\r
return (EFI_ACCESS_DENIED);\r
}\r
Status = gRT->GetTime(&FileInfo->ModificationTime, NULL);\r
- ASSERT_EFI_ERROR(Status);\r
+ if (EFI_ERROR(Status)) {\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"gRT->GetTime", Status);\r
+ return (SHELL_DEVICE_ERROR);\r
+ }\r
+\r
CopyMem(&FileInfo->LastAccessTime, &FileInfo->ModificationTime, sizeof(EFI_TIME));\r
\r
Status = gEfiShellProtocol->SetFileInfo(Handle, FileInfo);\r
return (Status);\r
}\r
\r
+/**\r
+ Touch a given file and potantially recurse down if it was a directory.\r
+\r
+ @param[in] Name The name of this file.\r
+ @param[in] FS The name of the file system this file is on.\r
+ @param[in] Handle The handle of this file already opened.\r
+ @param[in] Rec TRUE to recurse if possible.\r
+\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DoTouchByHandle (\r
\r
if (FS == NULL) {\r
FS = StrnCatGrow(&FS, NULL, Name, 0);\r
- TempSpot = StrStr(FS, L"\\");\r
- if (TempSpot != NULL) {\r
- *TempSpot = CHAR_NULL;\r
+ if (FS != NULL) {\r
+ TempSpot = StrStr(FS, L"\\");\r
+ if (TempSpot != NULL) {\r
+ *TempSpot = CHAR_NULL;\r
+ }\r
}\r
}\r
+ if (FS == NULL) {\r
+ return (EFI_INVALID_PARAMETER);\r
+ }\r
\r
//\r
// do it\r
//\r
Status = TouchFileByHandle(Handle);\r
if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Name, Status);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Name); \r
return (Status);\r
}\r
\r
//\r
Status = gEfiShellProtocol->OpenFileByName (Walker->FullName, &Walker->Handle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE);\r
if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Walker->FullName, Status);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Walker->FullName); \r
Status = EFI_ACCESS_DENIED;\r
} else {\r
Status = DoTouchByHandle(Walker->FullName, FS, Walker->Handle, TRUE);\r
Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);\r
if (EFI_ERROR(Status)) {\r
if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, ProblemParam);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, L"touch", ProblemParam); \r
FreePool(ProblemParam);\r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
// we insufficient parameters\r
//\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellLevel3HiiHandle, L"touch"); \r
ShellStatus = SHELL_INVALID_PARAMETER;\r
} else {\r
//\r
){\r
Status = ShellOpenFileMetaArg((CHAR16*)Param, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE, &FileList);\r
if (EFI_ERROR(Status)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel3HiiHandle, (CHAR16*)Param);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellLevel3HiiHandle, L"touch", (CHAR16*)Param); \r
ShellStatus = SHELL_NOT_FOUND;\r
break;\r
}\r
// check that we have at least 1 file\r
//\r
if (FileList == NULL || IsListEmpty(&FileList->Link)) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, Param);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NF), gShellLevel3HiiHandle, L"touch", Param); \r
continue;\r
} else {\r
//\r
// make sure the file opened ok\r
//\r
if (EFI_ERROR(Node->Status)){\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Node->Status);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName); \r
ShellStatus = SHELL_NOT_FOUND;\r
continue;\r
}\r
\r
Status = DoTouchByHandle(Node->FullName, NULL, Node->Handle, ShellCommandLineGetFlag(Package, L"-r"));\r
if (EFI_ERROR(Status) && Status != EFI_ACCESS_DENIED) {\r
- ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_NO_OPEN), gShellLevel3HiiHandle, Node->FileName, Status);\r
+ ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL), gShellLevel3HiiHandle, L"touch", Node->FileName); \r
ShellStatus = SHELL_NOT_FOUND;\r
}\r
}\r