Source code of Windows XP (NT5)
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.

101 lines
2.3 KiB

  1. # __________________________________________________________________________________
  2. #
  3. # Purpose:
  4. # PERL Script to emulate SLM's 'delfile' command
  5. #
  6. # Parameters:
  7. # See Usage below
  8. #
  9. # Output:
  10. # Perforce output or the appropriate error message or usage statement
  11. #
  12. # __________________________________________________________________________________
  13. #
  14. # Load common SLM wrapper subroutine module
  15. #
  16. use SlmSubs;
  17. #
  18. # Parse command line arguments
  19. #
  20. SlmSubs::ParseArgs(@ARGV);
  21. #
  22. # Call usage and exit if ParseArgs has set the Usage or InvalidFlag flags or there
  23. # were no arguments given
  24. #
  25. if ($Usage or $InvalidFlag or $NoArgumentsGiven)
  26. {
  27. print $ErrorMessage;
  28. &Usage;
  29. exit 1;
  30. }
  31. #
  32. # Need to have a file list
  33. #
  34. if ((!@FileList) and (!@DirList))
  35. {
  36. print "\n";
  37. print "Error: No files specified\n";
  38. print "\n";
  39. &Usage;
  40. exit 1;
  41. }
  42. system "$SourceControlClient revert @FileList @DirList> nul 2>&1";
  43. system "$SourceControlClient delete @FileList @DirList> nul 2>&1";
  44. #
  45. # Initialize lists
  46. #
  47. @DelFilesList = ();
  48. SlmSubs::CreateSubmitList("delete", \@DelFilesList);
  49. if (@DelFilesList)
  50. {
  51. @SubmitOutput = SlmSubs::PerforceRequest("submit", \@DelFilesList);
  52. print "@SubmitOutput";
  53. #
  54. # Remove any empty directories
  55. #
  56. if ($Recursive)
  57. {
  58. system "mtdir /d /e";
  59. }
  60. }
  61. else
  62. {
  63. print "There are no files to delete\n";
  64. }
  65. sub Usage
  66. # __________________________________________________________________________________
  67. #
  68. # Prints out a usage statement for this script. In this case usurped from SLM's
  69. # 'delfile' usage statement
  70. #
  71. # Parameters:
  72. # None
  73. #
  74. # Output:
  75. # The usage statement
  76. #
  77. # __________________________________________________________________________________
  78. {
  79. print q/Usage: delfile [-?fhr] [-c comment] [file1] [file2... ]
  80. Arguments:
  81. -h prints out this message.
  82. -r (recursive) removes all files in a given directory and in every
  83. subdirectory under that directory from the project. If no directory
  84. is specified in the file argument, the current directory is assumed.
  85. If a pattern is included, such as *.asm, only deletes files that match
  86. the pattern.
  87. -c supplies the same comment for all files (otherwise, you are prompted
  88. for one).
  89. /;
  90. }