Index: /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 10419)
+++ /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 10420)
@@ -1,5 +1,5 @@
 # Copyright (c) 2006  Paul Price, Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.7 2006-12-01 02:24:27 price Exp $
+# $Id: Config.pm,v 1.8 2006-12-03 18:43:40 eugene Exp $
 
 package PS::IPP::Config;
@@ -90,4 +90,49 @@
 }
 
+
+# select a datapath from config.site
+sub datapath
+{
+    my $self = shift;		# Configuration object
+    my $name = shift;		# datapath name
+
+    my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of cameras
+    my $pathname = _mdLookupStr($path_list, $name); # Filename of camera configuration
+    croak "Unable to find camera configuration file $pathname\n" if not defined $pathname;
+
+    return $pathname;
+}
+
+sub convert_filename
+{
+    my $self = shift;		# Configuration object
+    my $name = shift;		# raw name
+    my $base;
+
+    my $abspath = false;
+
+    # strip off file:// prefix
+    $name =~ s|^file://||;
+    
+    # replace path://PATH with datapath lookup
+    if ($name =~ m|^path://|) {
+	($base) = $name =~ m|^path://(.*)|;
+	my @list = split ("/", $base);
+	my $path = shift @list;
+	my $realpath = $self->datapath($path);
+	unshift @list, $realpath;
+	$name = join ("/", @list);
+    }
+
+    # if we have a relative path in the end, prepend WORKDIR
+    unless ($name =~ m|^/|) {
+	my $workdir = $self->workdir();
+	if defined $workdir {
+	    $name = File::Spec->rel2abs( $name, $workdir);
+	}
+    }
+
+    return $name;
+}
 
 # Return a rejection limit from the camera configuration
