torture_create_files.pl 548 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env perl
  2. use strict;
  3. use File::Path qw(make_path);
  4. use File::Basename qw(dirname);
  5. if (scalar @ARGV < 2) {
  6. print "Usage: $0 input.lay <offsetdir>\n";
  7. exit;
  8. }
  9. my ($file, $offset_dir) = @ARGV;
  10. open FILE, "<", $file or die $!;
  11. while (<FILE>) {
  12. my ($fillfile, $size) = split(/:/, $_);
  13. $fillfile = $offset_dir . '/' . $fillfile;
  14. my $dir = dirname $fillfile;
  15. if (!-d $dir) { make_path $dir; }
  16. open FILLFILE, ">", $fillfile;
  17. print "writing $fillfile with $size bytes\n...";
  18. print FILLFILE 0x01 x $size;
  19. close FILLFILE;
  20. }