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.

135 lines
2.8 KiB

  1. @REM -----------------------------------------------------------------
  2. @REM
  3. @REM SanityCheckUnicodeFiles.cmd - MikeR
  4. @REM Ensure that commonly messed up Unicode files have the proper
  5. @REM FFFE "signature" on the front of the file.
  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 Logmsg;
  19. use UnicodeCheck;
  20. sub Usage { print<<USAGE; exit(1) }
  21. SanityCheckUnicodeFiles.cmd
  22. Ensure that commonly messed up Unicode files have the proper "FFFE"
  23. Unicode signature on the front of the file.
  24. We read the list of files to sanity check from
  25. "$ENV{RAZZLETOOLPATH}\\PostBuildScripts\\SanityCheckList.txt".
  26. All paths we obtain are appended to "$ENV{_NTDRIVE}$ENV{_NTROOT}\\"
  27. to produce the final path to the file to be checked.
  28. USAGE
  29. parseargs('?' => \&Usage);
  30. my $BasePath = "$ENV{_NTDRIVE}$ENV{_NTROOT}";
  31. my $FileList = "$ENV{RAZZLETOOLPATH}\\PostBuildScripts\\SanityCheckList.txt";
  32. logmsg( "Reading file list to sanity check from '$FileList'..." );
  33. #
  34. # Read the file list in
  35. #
  36. # We assume things will be in the \NT tree and in the format of:
  37. #
  38. # \mergedcomponents\setupinfs\usa\intl.txt
  39. #
  40. my @FilesToSanityCheck;
  41. my $ThisLine;
  42. if ( open(FILELIST, $FileList ) )
  43. {
  44. while ( <FILELIST> )
  45. {
  46. # Save off the line so we can use it...
  47. $ThisLine = $_;
  48. # Chop off any trailing newline...
  49. $ThisLine =~ s/\n$//;
  50. # We only care about this if it's not a comment line...
  51. if ( $ThisLine =~ /^\;/ )
  52. {
  53. # printf( "Comment Line : $ThisLine\n" );
  54. }
  55. else
  56. {
  57. # printf( "Data Line : $ThisLine\n" );
  58. # Build the correct path...
  59. my $FilePath;
  60. $FilePath = $BasePath;
  61. if ( ! ($ThisLine =~ /^\\/) )
  62. {
  63. $FilePath .= "\\";
  64. }
  65. $FilePath .= $ThisLine;
  66. # Append this file path to the array...
  67. push( @FilesToSanityCheck, $FilePath );
  68. }
  69. }
  70. # Close the file...
  71. close( FILELIST );
  72. }
  73. my $NumFiles = @FilesToSanityCheck;
  74. if ( $NumFiles < 1 )
  75. {
  76. wrnmsg( "No files to sanity check!" );
  77. }
  78. logmsg( "Checking $NumFiles file(s) for valid Unicode signatures..." );
  79. #
  80. # Sanity check each file in the list
  81. #
  82. my $ThisFile;
  83. foreach $ThisFile (@FilesToSanityCheck)
  84. {
  85. IsFileUnicode( $ThisFile );
  86. }
  87. logmsg( "Done checking Unicode signatures." );