torture_create_files.pl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env perl
  2. #
  3. # Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. # for more details.
  14. #
  15. use strict;
  16. use File::Path qw(make_path);
  17. use File::Basename qw(dirname);
  18. if (scalar @ARGV < 2) {
  19. print "Usage: $0 input.lay <offsetdir>\n";
  20. exit;
  21. }
  22. my ($file, $offset_dir) = @ARGV;
  23. open FILE, "<", $file or die $!;
  24. while (<FILE>) {
  25. my ($fillfile, $size) = split(/:/, $_);
  26. $fillfile = $offset_dir . '/' . $fillfile;
  27. my $dir = dirname $fillfile;
  28. if (!-d $dir) { make_path $dir; }
  29. open FILLFILE, ">", $fillfile;
  30. print "writing $fillfile with $size bytes\n...";
  31. print FILLFILE 0x01 x $size;
  32. close FILLFILE;
  33. }