#!/usr/bin/perl
use Gnome2::VFS;
use warnings;
use strict;

Gnome2::VFS->init;

my $uri = sprintf('file://%s', $ARGV[0]);

my ($result, $info) = Gnome2::VFS->get_file_info($uri, 'get-mime-type');
if ($result ne 'ok') {
	print STDERR "Error opening '$uri': $result\n";
	return 1;
}

my $mime = Gnome2::VFS::Mime::Type->new($info->get_mime_type);
if (!defined($mime)) {
	print STDERR "Cannot get MIME type for '$uri'\n";
	return 1;
}

my $app = $mime->get_default_application;
if (!defined($app)) {
	print STDERR "Cannot get application for '$uri' (type ".$info->get_mime_type.")\n";
	return 1;

} else {
	use Data::Dumper;
	print Dumper($app);

}

$app->launch($uri);
