genfiles #1

  • //
  • guest/
  • richard_geiger/
  • p4bench/
  • genfiles
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#!/usr/local/bin/perl
# -*-Fundamental-*-

my ($Path, $Files_per_dir, $Width, $Depth) =  @ARGV;

$ngened = 0;

sub gen
{
  my ($depth, $path) = @_;
  if ($depth <= $Depth)
    {
      $depth++;
      # make dirs and recurse
      for (my $dn = 1; $dn <= $Width; $dn++)
         {
           my $dname = sprintf "d_%02d", $dn;
           mkdir $dname, 0755 || die "mkdir $path/$dname: $!";
           chdir $dname || die "chdir $path/$dname: $!";
           &gen($depth, "$path/$dname");
	   chdir ".." ||  die "chdir ..";
         }
    }
  else
    {
      # we're in a leaf... make files
      for (my $fn = 1; $fn <= $Files_per_dir; $fn++)
        {
          my $fname = sprintf "f_%05d", $fn;
          open(F, ">$fname") || die;
          close F;
	  $ngened++;
        }
    }
}
  
$Path = "${Path}_$Files_per_dir-$Width-$Depth";

if (-d $Path)
  {
    print "$Path already exists; nothing done.\n";
    exit 0;
  }

if (system "mkdir -p $Path") { die "mkdir -p $Path"; }

chdir $Path || die "chdir $Path: $!";

&gen(1, $Path);

print "created $ngened files in $Path\n";

exit 0;

# Change User Description Committed
#1 904 rmg Add these for the client_delete test