print "#!/usr/local/bin/dot
# Automatically generated file.
# Contains the directory representation of $ARGV[0] generated by $0
#
";
if ($ print STDERR "$0: usage $0 directory\n";
exit(1);
}
$unix = (-r '/dev/null');
if ($unix) {
open(IN, $cmd = "find $ARGV[0] -type d -print|") || die "Unable to run $cmd: $!\n";
} else {
open(IN, $cmd = "dir /b/ad/s $ARGV[0]|") || die "Unable to run $cmd: $!\n";
}
while (<IN>) {
chop;
if ($unix) {
@paths = split(/\//, $_);
} else {
@paths = split(/\\/, $_);
}
undef $op;
undef $path;
for $p (@paths) {
$path .= "/$p";
$name = $path;
$name =~ s/[^a-zA-Z0-9]/_/g;
$node{$name} = $p;
$edge{"$op->$name;"} = 1 if ($op);
$op = $name;
}
}
close(IN);
print 'digraph G {
nodesep=.1;
rankdir=LR;
node [height=.15,shape=box,fontname="Helvetica",fontsize=8];
edge [arrowhead=none,arrowtail=none];
'
;
for $i (sort keys %node) {
print "\t$i [label=\"$node{$i}\"];\n";
}
for $i (sort keys %edge) {
print "\t$i\n";
}
print "}\n";