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.

96 lines
2.2 KiB

  1. @echo off
  2. for %%i in (%0.cmd) do perl -w -x %%~dp$PATH:i%0.cmd %*
  3. goto :eof
  4. #!perl
  5. # line 6
  6. #
  7. # FileName: sdonline.cmd
  8. #
  9. # Usage = sdonline [-v]
  10. #
  11. # This script cleans up after sdout and does SD ONLINE on all files listed
  12. # in the sd.offline file at the root of the depot.
  13. #
  14. #
  15. use Cwd;
  16. use Getopt::Std;
  17. #
  18. # initialize globals
  19. #
  20. $opt_v = 0;
  21. $Usage = "
  22. USAGE: $0 [-v]
  23. -v Verbose output\n";
  24. #
  25. # given a path, finds the directory above it that contains SD.INI
  26. # (and SD.OFFLINE)
  27. # pathname should be passed as a list of components rather than as
  28. # a string
  29. #
  30. sub findSDroot {
  31. my $temppath;
  32. while (@_) {
  33. $temppath = join('\\', @_);
  34. $opt_v and print "checking $temppath for SD.INI\n";
  35. if (-e ($temppath . "\\sd.ini")) {
  36. return($temppath);
  37. }
  38. #
  39. # remove the last component
  40. #
  41. pop;
  42. }
  43. }
  44. #
  45. # process options
  46. #
  47. getopts('v') or die $Usage;
  48. if ($opt_v) {
  49. print "Verbose mode\n";
  50. }
  51. @components = split(/[\/\\]/, cwd());
  52. $SDRoot = findSDroot(@components) or die "no SD.INI found in path";
  53. $fn = $SDRoot . "\\sd.offline";
  54. if (-e $fn) {
  55. $opt_v and print "opening file $fn\n";
  56. open(OFFLINEFILE, $fn) or die "couldn't open $fn: $!\n";
  57. @offlinefiles = <OFFLINEFILE>;
  58. print "Currently offline files:\n";
  59. foreach $file (@offlinefiles) {
  60. chop $file and print "\t$file\n";
  61. }
  62. `ync /c yn Do you want to run "sd online" on these files?`;
  63. if ($? == 0) {
  64. foreach $file (@offlinefiles) {
  65. $opt_v and print "running SD ONLINE $file\n";
  66. `sd online $file`;
  67. if ($_) {
  68. #
  69. # sd online failed, keep this file on the list
  70. #
  71. $opt_v and print "sd online $file failed\n";
  72. push @newofflinefiles, $file;
  73. }
  74. }
  75. #
  76. # rewrite the sd.offline file with files that couldn't be
  77. # checked out
  78. #
  79. open(OFFLINEFILE, "+> $fn") or die "couldn't reopen $fn: $!\n";
  80. foreach $file (@newofflinefiles) {
  81. print OFFLINEFILE $file,"\n";
  82. }
  83. }
  84. } else {
  85. print "There are currently no offline files\n";
  86. }