Index: trunk/psModules/src/camera/pmFPAfileDefine.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 13451)
+++ trunk/psModules/src/camera/pmFPAfileDefine.c	(revision 13496)
@@ -84,5 +84,6 @@
     // XXX ppFocus wants to override the selection with the new selection
     // XXX require programs like ppFocus to remove existing files by hand
-    if (!psMetadataAddPtr (config->files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file)) {
+    if (!psMetadataAddPtr (config->files, PS_LIST_TAIL, name,
+                           PS_DATA_UNKNOWN | PS_META_DUPLICATE_OK, "", file)) {
         psError (PS_ERR_IO, false, "could not add %s to config files", name);
         return NULL;
Index: trunk/psModules/src/camera/pmFPAfileDefine.h
===================================================================
--- trunk/psModules/src/camera/pmFPAfileDefine.h	(revision 13451)
+++ trunk/psModules/src/camera/pmFPAfileDefine.h	(revision 13496)
@@ -4,6 +4,6 @@
  * @author EAM, IfA
  *
- * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
- * @date $Date: 2007-04-14 03:01:11 $
+ * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
+ * @date $Date: 2007-05-24 02:38:07 $
  * Copyright 2004-2005 Institute for Astronomy, University of Hawaii
  */
@@ -18,5 +18,6 @@
 //
 // Note that the returned pmFPAfile is a view only, so it should not be freed by the caller --- the only
-// reference count is held by the config->files metadata.
+// reference count is held by the config->files metadata.  Multiple file rules of the same name are permitted
+// if multiple is true.
 pmFPAfile *pmFPAfileDefineInput (const pmConfig *config, pmFPA *fpa, const char *name);
 
Index: trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileIO.c	(revision 13451)
+++ trunk/psModules/src/camera/pmFPAfileIO.c	(revision 13496)
@@ -5,5 +5,5 @@
 #include <stdio.h>
 #include <string.h>
-#include <strings.h>		/* for strn?casecmp */
+#include <strings.h>            /* for strn?casecmp */
 #include <pslib.h>
 
@@ -661,7 +661,7 @@
       case PM_FPA_FILE_HEADER:
       case PM_FPA_FILE_FRINGE:
-	// XXX note that for CMF and PSF, we do not know yet if there is actually any data to 
-	// write out.  this is because these types of output files have their data stored on the
-	// readout->analysis metadata structure of another (existing) fpa
+        // XXX note that for CMF and PSF, we do not know yet if there is actually any data to
+        // write out.  this is because these types of output files have their data stored on the
+        // readout->analysis metadata structure of another (existing) fpa
       case PM_FPA_FILE_CMF:
       case PM_FPA_FILE_PSF:
@@ -848,34 +848,32 @@
     PS_ASSERT_PTR_NON_NULL(files, false);
 
-    if (!name) {
-        psMetadataItem *item = NULL;
-        psMetadataIterator *iter = psMetadataIteratorAlloc (files, PS_LIST_HEAD, NULL);
-        while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
-            pmFPAfile *file = item->data.V;
-            if (state) {
-                file->state &= PS_NOT_U8(PM_FPA_STATE_INACTIVE);
-            } else {
-                file->state |= PM_FPA_STATE_INACTIVE;
-            }
-        }
-        psFree (iter);
-        return true;
-    }
-
-    bool status = false;
-    pmFPAfile *file = psMetadataLookupPtr (&status, files, name);
-    if (!status) {
-        psTrace("psModules.camera", 6, "%s is not a defined IO file", name);
-        return false;
-    }
-    if (!file) {
-        psError(PS_ERR_IO, true, "file %s is NULL", name);
-        return false;
-    }
-    if (state) {
-        file->state &= PS_NOT_U8(PM_FPA_STATE_INACTIVE);
-    } else {
-        file->state |= PM_FPA_STATE_INACTIVE;
-    }
-    return true;
-}
+    // Do this as an iteration rather than a lookup, since we may want to turn on/off multiple files at once
+    // (if there are multiple files defined with the same name).
+
+    psString regex = NULL;              // Regular expression for psMetadataIteratorAlloc
+    if (name) {
+        psStringAppend(&regex, "^%s$", name);
+    }
+
+    int num = 0;                        // Number of files activated
+    psMetadataItem *item = NULL;        // Item from iteration
+    psMetadataIterator *iter = psMetadataIteratorAlloc(files, PS_LIST_HEAD, regex); // Iterator
+    while ((item = psMetadataGetAndIncrement(iter))) {
+        pmFPAfile *file = item->data.V; // File of interest
+        if (state) {
+            file->state &= PS_NOT_U8(PM_FPA_STATE_INACTIVE);
+        } else {
+            file->state |= PM_FPA_STATE_INACTIVE;
+        }
+        num++;
+    }
+    psFree(iter);
+    psFree(regex);
+
+    if (num == 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find any files matching %s", name);
+        return false;
+    }
+
+    return true;
+}
