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.

74 lines
2.1 KiB

  1. $SSDIR = "C:\\Progra~1\\Micros~3\\Common\\VSS";
  2. $SSCMD = "$SSDIR\\Win32\\ss";
  3. $SSOPTIONS = "-I-N";
  4. while ($_ = $ARGV[0], /^-/) {
  5. shift;
  6. last if /^--$/;
  7. /^-s(.*)/i && ($ssdb = $1);
  8. /^-d(.*)/i && ($targetroot = $1);
  9. /^-f(.*)/i && ($projectfile = $1);
  10. /^-p(.*)/i && ($platformfilter = $1);
  11. }
  12. ($targetroot && $projectfile) || die "Usage: FetchProjects.pl [-S<SourceSafe Database>] -D<target root dir> -F<project ini file> [-P<platform filter>]\n";
  13. open (FILE, $projectfile) || die "Error opening $projectfile!\n";
  14. while (<FILE>) {
  15. /^\[(.*)\]/ && ($projectname = $1);
  16. if ( $projectname ) {
  17. /^Directory=(.*)/i && ($directory{$projectname} = $1);
  18. /^Platform=(.*)/i && ($platform{$projectname} = $1);
  19. /^Recursive=(.*)/i && ($recursive{$projectname} = $1);
  20. }
  21. }
  22. close FILE;
  23. $ssfile = "$SSDIR\\srcsafe.ini";
  24. if ( $ssdb ) {
  25. rename ("$ssfile", "$ssfile.bak") || die "Error renaming $ssfile to $ssfile.bak: $!.\n";
  26. open (OUTFILE, ">$ssfile") || die "Error opening file $ssfile: $!.\n";
  27. print OUTFILE "#include $ssdb\\srcsafe.ini\n";
  28. close OUTFILE;
  29. print "Using $ssdb\n";
  30. }
  31. else {
  32. open (INFILE, "$ssfile") || die "Error opening $ssfile: $!.\n";
  33. while (<INFILE>) {
  34. /^#include (.*)\\srcsafe.ini/ && (print "Using $1\n");
  35. }
  36. close INFILE;
  37. }
  38. if ( ! -d $targetroot ) {
  39. system "md \"$targetroot\"";
  40. print "Created directory $targetroot\n";
  41. }
  42. foreach $project (sort keys %directory) {
  43. if ( !$platformfilter || ($platform{$project} =~ /$platformfilter/i) ) {
  44. print "\nGetting project $project...\n";
  45. $targetdir = "$targetroot\\$directory{$project}";
  46. if ( ! -d $targetdir ) {
  47. system "md \"$targetdir\"";
  48. print "Created directory $targetdir\n";
  49. }
  50. if ( $recursive{$project} eq "No" ) {
  51. $command = "$SSCMD get \"$project\" $SSOPTIONS \"-GL$targetdir\"";
  52. }
  53. else {
  54. $command = "$SSCMD get \"$project\" -R $SSOPTIONS \"-GL$targetdir\"";
  55. }
  56. print "$command\n";
  57. system "$command";
  58. }
  59. }
  60. if ( $ssdb ) {
  61. rename ("$ssfile.bak", "$ssfile") || die "Error renaming $ssfile.bak to $ssfile: $!.\n";
  62. }
  63. exit 0;