Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 1998 Intel Corporation
  3. Module Name:
  4. touch.c
  5. Abstract:
  6. Shell app "touch" - touches the files last modification time
  7. Revision History
  8. --*/
  9. #include "shell.h"
  10. /*
  11. *
  12. */
  13. EFI_STATUS
  14. InitializeTouch (
  15. IN EFI_HANDLE ImageHandle,
  16. IN EFI_SYSTEM_TABLE *SystemTable
  17. );
  18. VOID
  19. TouchFile (
  20. IN SHELL_FILE_ARG *Arg
  21. );
  22. /*
  23. *
  24. */
  25. EFI_DRIVER_ENTRY_POINT(InitializeTouch)
  26. EFI_STATUS
  27. InitializeTouch (
  28. IN EFI_HANDLE ImageHandle,
  29. IN EFI_SYSTEM_TABLE *SystemTable
  30. )
  31. {
  32. CHAR16 **Argv;
  33. UINTN Argc;
  34. UINTN Index;
  35. LIST_ENTRY FileList;
  36. LIST_ENTRY *Link;
  37. SHELL_FILE_ARG *Arg;
  38. /*
  39. * Check to see if the app is to install as a "internal command"
  40. * to the shell
  41. */
  42. InstallInternalShellCommand (
  43. ImageHandle, SystemTable, InitializeTouch,
  44. L"touch", /* command */
  45. L"touch [filename]", /* command syntax */
  46. L"View/sets file attributes", /* 1 line descriptor */
  47. NULL /* command help page */
  48. );
  49. /*
  50. * We are no being installed as an internal command driver, initialize
  51. * as an nshell app and run
  52. */
  53. InitializeShellApplication (ImageHandle, SystemTable);
  54. Argv = SI->Argv;
  55. Argc = SI->Argc;
  56. InitializeListHead (&FileList);
  57. /*
  58. * Expand each arg
  59. */
  60. for (Index = 1; Index < Argc; Index += 1) {
  61. ShellFileMetaArg (Argv[Index], &FileList);
  62. }
  63. /*
  64. * Attrib each file
  65. */
  66. for (Link=FileList.Flink; Link!=&FileList; Link=Link->Flink) {
  67. Arg = CR(Link, SHELL_FILE_ARG, Link, SHELL_FILE_ARG_SIGNATURE);
  68. TouchFile (Arg);
  69. }
  70. ShellFreeFileList (&FileList);
  71. return EFI_SUCCESS;
  72. }
  73. VOID
  74. TouchFile (
  75. IN SHELL_FILE_ARG *Arg
  76. )
  77. {
  78. EFI_STATUS Status;
  79. Status = Arg->Status;
  80. if (!EFI_ERROR(Status)) {
  81. RT->GetTime (&Arg->Info->ModificationTime, NULL);
  82. Status = Arg->Handle->SetInfo(
  83. Arg->Handle,
  84. &GenericFileInfo,
  85. (UINTN) Arg->Info->Size,
  86. Arg->Info
  87. );
  88. }
  89. if (EFI_ERROR(Status)) {
  90. Print (L"touch: %s : %hr\n", Arg->FullName, Status);
  91. } else {
  92. Print (L"touch: %s [ok]\n", Arg->FullName);
  93. }
  94. }