Index: /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
===================================================================
--- /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 9869)
+++ /trunk/PS-IPP-Config/lib/PS/IPP/Config.pm	(revision 9870)
@@ -1,5 +1,5 @@
 # Copyright (c) 2006  Paul Price, Joshua Hoblitt
 #
-# $Id: Config.pm,v 1.2 2006-10-12 20:12:14 price Exp $
+# $Id: Config.pm,v 1.3 2006-11-07 03:18:39 price Exp $
 
 package PS::IPP::Config;
@@ -142,4 +142,43 @@
 }
 
+# Return a filename from the camera configuration FILERULES
+sub filename
+{
+    my $self = shift;		# Configuration object
+    my $name = shift;		# Name of the file
+    my $output = shift;		# For replacing {OUTPUT}
+    my $component = shift;	# For replacing {CHIP.NAME} and {CELL.NAME}
+
+    my $camera = $self->{camera}; # Camera configuration
+    unless (defined $camera) {
+	carp "Camera has not yet been defined.\n";
+	return undef;
+    }
+
+    my $filerules = _mdLookupMD($camera, 'FILERULES');	# File rules
+    unless (defined $filerules) {
+	carp "Can't find FILERULES list in camera configuration.\n";
+	return undef;
+    }
+
+    my $file = _mdLookupMD($filerules, $name); # The file of interest
+    unless (defined $file) {
+	carp "Can't find $name within FILERULES in camera configuration.\n";
+	return undef;
+    }
+
+    my $filename = _mdLookupStr($file, "FILENAME.RULE"); # File name
+    unless (defined $filename) {
+	carp "Can't find FILENAME.RULE for $name within FILERULES in camera configuration.\n";
+	return undef;
+    }
+
+    $filename =~ s/\{OUTPUT\}/$output/;
+    $filename =~ s/\{CHIP\.NAME\}/$component/;
+    $filename =~ s/\{CELL\.NAME\}/$component/;
+
+    return $filename;
+}   
+
 
 # Lookup the metadata, checking the type is STR
