Index: /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 10530)
+++ /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 10531)
@@ -1,5 +1,5 @@
 # Copyright (c) 2006  Paul Price, Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.11 2006-12-05 03:15:03 price Exp $
+# $Id: Config.pm,v 1.12 2006-12-07 22:47:12 price Exp $
 
 package PS::IPP::Config;
@@ -97,6 +97,6 @@
     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
+    my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths
+    my $pathname = _mdLookupStr($path_list, $name); # Path of interest
     croak "Unable to find camera configuration file $pathname\n" if not defined $pathname;
 
@@ -104,5 +104,5 @@
 }
 
-sub convert_filename
+sub convert_filename_absolute
 {
     my $self = shift;		# Configuration object
@@ -123,10 +123,40 @@
     }
 
-    # 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 );
-	}
+    $name =~ s|/{2,}|/|g;		# Remove double slashes
+
+    return $name;
+}
+
+sub convert_filename_relative
+{
+    my $self = shift;		# Configuration object
+    my $name = shift;		# raw name
+
+    $name =~ s|/{2,}|/|g;		# Remove double slashes
+
+    my $path_list = _mdLookupMD($self->{_ipprc}, 'DATAPATH'); # List of paths
+    my $best_path;
+    my $best_name;
+    my $best_score = length $name;
+    foreach my $path_item (@$path_list) {
+	my $path_name = $path_item->{name}; # Name of the path
+	my $path = $path_item->{value}; # The path
+	if ($path !~ m|/$|) {
+	    $path .= '/';
+	}
+	my ($rest) = $name =~ m|^$path(.*)|; # Rest of the string
+	next if not defined $rest;
+	my $score = length $rest;
+	if ($score < $best_score) {
+	    $best_path = $path;
+	    $best_score = $score;
+	    $best_name = $path_name;
+	}
+    }
+    if ($best_score < length $name) {
+	$name =~ s|^$best_path|path://$best_name/|;
+    } else {
+	# Worst case scenario: can't find anything, so put in the absolute path
+	$name = 'file://' . $name;
     }
 
