#!/usr/bin/perl -w

use strict;
use Sys::Guestfs;

my $dom = "Win7x32";
my $root = "/dev/sda2";
my $trace = 0;
#my $trace = 1;

my $g = Sys::Guestfs->new ();
$g->set_trace ($trace);
$g->add_domain ($dom, readonly => 1);
$g->launch ();
$g->mount ($root, "/");

sub test_exists {
    print "Does /Temp/V2V exist? ";
    if ($g->is_dir ($g->case_sensitive_path ("/Temp/V2V"))) {
        print "yes\n";
    } else {
        print "no\n";
    }
}

sub create_dir {
    my $path = '';
    for my $d ('Temp', 'V2V') {
        $path .= '/'.$d;

        $path = $g->case_sensitive_path($path);
        $g->mkdir_p($path);
    }
}

test_exists ();
# Try to create it.
create_dir ();
test_exists ();
# Trying to create it again should not fail.
create_dir ();
test_exists ();
