Advertisement
Guest User

Tomato recreate rstats binary file

a guest
Feb 18th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.69 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3.  
  4. my ($i, $j, $fh, @full_file);
  5. open $fh, ">:raw", 'tomato_rstats_generated.raw' || die "Cannot open file: $!";
  6.  
  7. while (<>) {
  8.     chomp;
  9.     push @full_file, $_;
  10.     }
  11.  
  12. $j = 0;
  13. syswrite $fh, pack("q", $full_file[$j++]);
  14.  
  15. $i = -1;
  16. while (++$i < 62) {
  17.     syswrite $fh, pack("q", $full_file[$j++]);
  18.     syswrite $fh, pack("q", $full_file[$j++]);
  19.     syswrite $fh, pack("q", $full_file[$j++]);
  20.     }
  21.  
  22. syswrite $fh, pack("q", $full_file[$j++]);
  23.  
  24. $i = -1;
  25. while (++$i < 25) {
  26.     syswrite $fh, pack("q", $full_file[$j++]);
  27.     syswrite $fh, pack("q", $full_file[$j++]);
  28.     syswrite $fh, pack("q", $full_file[$j++]);
  29.     }
  30.  
  31. syswrite $fh, pack("q", $full_file[$j]);
  32.  
  33. close $fh;
  34. exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement