sub mkdir_p
{
    my $dir = shift;
    my $mode = shift;
    my $cur_path = (($dir =~ s,^/,,) ? "/" : "");
    my @components = split('/', $dir);
    while (@components)
    {
	$cur_path .= shift(@components);
	mkdir $cur_path, $mode;
	$cur_path .= "/";
    }
}
