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.

63 lines
1.6 KiB

  1. @echo off
  2. REM ------------------------------------------------------------------
  3. REM
  4. REM nullcopy.cmd - JeremyD
  5. REM Fix up null files by force copying files reported by nullfile
  6. REM
  7. REM Copyright (c) Microsoft Corporation. All rights reserved.
  8. REM
  9. REM ------------------------------------------------------------------
  10. perl -x "%~f0" %*
  11. goto :EOF
  12. #!perl
  13. use strict;
  14. use lib $ENV{RAZZLETOOLPATH} . "\\PostBuildScripts";
  15. use lib $ENV{RAZZLETOOLPATH};
  16. use PbuildEnv;
  17. use ParseArgs;
  18. use File::Copy;
  19. sub Usage { print<<USAGE; exit(1) }
  20. nullcopy [-list:<null file list>] <source> <destination>
  21. Files in the destination reported as bad by nullfile.exe will be
  22. copied from the source. The -list option can be used to specifiy a
  23. text file containing the output from a previous run of nullfile.exe.
  24. USAGE
  25. my ($listfile, $src, $dst);
  26. parseargs('?' => \&Usage,
  27. 'list:' => \$listfile,
  28. \$src,
  29. \$dst);
  30. if (!-d $src or !-d $dst or @ARGV) {
  31. Usage();
  32. }
  33. my @lines;
  34. if ($listfile) {
  35. open FILE, $listfile
  36. or die "Failed to read file list from $listfile: $!\n";
  37. @lines = <FILE>;
  38. close FILE;
  39. }
  40. else {
  41. # would be nice to check for an error here, but you'd have to
  42. # parse the output
  43. @lines = `nullfile.exe $dst`;
  44. }
  45. for my $line (@lines) {
  46. # extract filename relative to destination directory
  47. # from nullfile.exe output
  48. my ($file) = $line =~ /\Q$dst\E\\(\S+)/i;
  49. if ($file) {
  50. if (-e "$src\\$file") {
  51. print "Copying $src\\$file to $dst\\$file\n";
  52. copy("$src\\$file" => "$dst\\$file");
  53. }
  54. }
  55. }