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.

78 lines
2.2 KiB

  1. # mergetoks.pl
  2. # Extract resources from a directory tree of resource DLL's
  3. # And merge to a single token file
  4. # Owner: nadima
  5. #
  6. # Usage perl mergetoks.pl rcdll.dll outputfile.tok
  7. #
  8. # Scans all subdirectories looking for rcdll.dll instances
  9. # to extract resources and merge
  10. #
  11. if (@ARGV != 2) {
  12. print "Usage: perl mergetoks.pl rcdll.dll outputfilename.tok\n\n";
  13. print "Scans all subdirectories looking for rcdll.dll instances\n";
  14. print "to extract resources and merge into outputfile.tok\n";
  15. exit(1);
  16. }
  17. $resdllname = shift;
  18. $outputname = shift;
  19. print "Extracting resources for all subdirs\\" . $resdllname . " to " . $outputname . "\n";
  20. $dir = ".";
  21. opendir DIR, $dir || die "cannot open $dir";
  22. @list = readdir(DIR);
  23. closedir(DIR);
  24. # Walk the first level subdirectories
  25. # looking for resource DLLs
  26. $extractcount = 0;
  27. foreach (@list) {
  28. if ( !($_ eq '.') && !($_ eq '..') && (-d "$dir/$_") ) {
  29. if (-f "$dir/$_/$resdllname") {
  30. print "Extracting resources from: " . $_ . "...\n";
  31. # run 'rsrc msrdprc.dll -t foo.tk'
  32. if (system "rsrc $dir\\$_\\$resdllname -t $_.tk > NULL") {
  33. print ("rsrc $dir\\$_\\$resdllname failed!\n");
  34. exit (1);
  35. }
  36. else {
  37. $extractcount++;
  38. }
  39. }
  40. }
  41. }
  42. print "Extracted: " . $extractcount . " language resources.\n";
  43. print "Merging resources to $outputname\n";
  44. opendir DIR, $dir || die "cannot open $dir";
  45. @filelist = readdir(DIR);
  46. closedir(DIR);
  47. # Walk the list of TK files and merge them together
  48. # Take the whole first file and then skip the first line
  49. # from all the other files (to skip the UNICODE BOM)
  50. open (OUTPUTFILE, ">> ./$outputname") or die "Error can't open outfile: $outputname\n";
  51. $skipfirstline = 0;
  52. foreach (@filelist) {
  53. if (/tk/) {
  54. print "Merging file: $_\n";
  55. open (INFILE, "$dir/$_") or die "Error can't open infile: $_\n";
  56. $lineNo = 0;
  57. while(<INFILE>)
  58. {
  59. if ($lineNo++ == 0 && $skipfirstline) {
  60. next;
  61. }
  62. print OUTPUTFILE "$_";
  63. }
  64. close(INFILE);
  65. #Skip the first line of every file after the first one
  66. $skipfirstline = 1;
  67. }
  68. }
  69. close(OUTPUTFILE);