Index: trunk/psModules/src/camera/pmFPAfile.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfile.c	(revision 7529)
+++ trunk/psModules/src/camera/pmFPAfile.c	(revision 7589)
@@ -5,20 +5,20 @@
 #include "pmHDU.h"
 #include "pmFPA.h"
-#include "pmFPAMaskWeight.h"
+// #include "pmFPAMaskWeight.h"
 #include "pmFPAConstruct.h"
 #include "pmFPAview.h"
 #include "pmFPAfile.h"
 #include "pmFPACopy.h"
-#include "pmFPARead.h"
-#include "pmFPAWrite.h"
-#include "pmPeaks.h"
-#include "pmMoments.h"
-#include "pmModel.h"
-#include "pmSource.h"
-#include "pmSourceIO.h"
-#include "pmGrowthCurve.h"
-#include "pmPSF.h"
-#include "pmPSF_IO.h"
-#include "pmFPA_JPEG.h"
+// #include "pmFPARead.h"
+// #include "pmFPAWrite.h"
+// #include "pmPeaks.h"
+// #include "pmMoments.h"
+// #include "pmModel.h"
+// #include "pmSource.h"
+// #include "pmSourceIO.h"
+// #include "pmGrowthCurve.h"
+// #include "pmPSF.h"
+// #include "pmPSF_IO.h"
+// #include "pmFPA_JPEG.h"
 
 static void pmFPAfileFree(pmFPAfile *file)
@@ -33,4 +33,5 @@
     psFree (file->names);
 
+    psFree (file->camera);
     psFree (file->format);
     psFree (file->name);
@@ -48,8 +49,4 @@
     psFree (file->extname);
 
-    // these are just views ??
-    // psFree (file->phu);
-    // psFree (file->header);
-
     return;
 }
@@ -68,4 +65,5 @@
     file->names = psMetadataAlloc();
 
+    file->camera = NULL;
     file->format = NULL;
     file->name = NULL;
@@ -86,738 +84,4 @@
 }
 
-static const char *depthEnumToName(pmFPAdepth depth)
-{
-    const char *val = NULL;
-
-    switch (depth) {
-    case PM_FPA_DEPTH_NONE:
-        val = "NONE";
-        break;
-    case PM_FPA_DEPTH_FPA:
-        val = "FPA";
-        break;
-    case PM_FPA_DEPTH_CHIP:
-        val = "CHIP";
-        break;
-    case PM_FPA_DEPTH_CELL:
-        val = "CELL";
-        break;
-    case PM_FPA_DEPTH_READOUT:
-        val = "READOUT";
-        break;
-    default:
-        psAbort(PS_FILE_LINE, "You can't get here; depth = %d", depth);
-    }
-
-    return val;
-}
-
-static pmFPAdepth depthNameToEnum(const char *name)
-{
-    pmFPAdepth val;
-
-    if (name == NULL) {
-        val = PM_FPA_DEPTH_NONE;
-    } else if (!strcasecmp(name, "FPA"))     {
-        val = PM_FPA_DEPTH_FPA;
-    } else if (!strcasecmp(name, "CHIP"))    {
-        val = PM_FPA_DEPTH_CHIP;
-    } else if (!strcasecmp(name, "CELL"))    {
-        val = PM_FPA_DEPTH_CELL;
-    } else if (!strcasecmp(name, "READOUT")) {
-        val = PM_FPA_DEPTH_READOUT;
-    } else {
-        val = PM_FPA_DEPTH_NONE;
-    }
-
-    return val;
-}
-
-// define a pmFPAfile, bind to the optional fpa if supplied
-pmFPAfile *pmFPAfileDefine(psMetadata *files, psMetadata *camera, pmFPA *fpa, char *name)
-{
-    PS_ASSERT_PTR_NON_NULL(files, NULL);
-    PS_ASSERT_PTR_NON_NULL(camera, NULL);
-    PS_ASSERT_PTR_NON_NULL(name, NULL);
-    PS_ASSERT_INT_POSITIVE(strlen(name), NULL);
-
-    bool status;
-    char *type;
-
-    // select the FILERULES from the camera config
-    psMetadata *filerules = psMetadataLookupPtr (&status, camera, "FILERULES");
-    if (filerules == NULL) {
-        psError(PS_ERR_IO, true, "Can't find FILERULES in the CAMERA configuration!");
-        return NULL;
-    }
-
-    // select the name from the FILERULES
-    // check for alias name (type == STR, name is aliased name)
-    char *realname = psMetadataLookupStr (&status, filerules, name);
-    if (!realname || strlen(realname) == 0) {
-        realname = name;
-    }
-
-    psMetadata *data = psMetadataLookupPtr (&status, filerules, realname);
-    if (data == NULL) {
-        psError(PS_ERR_IO, true, "Can't find file concept %s!", name);
-        return NULL;
-    }
-
-    pmFPAfile *file = pmFPAfileAlloc ();
-
-    // save the name of this pmFPAfile
-    file->name = psStringCopy (name);
-
-    file->filerule = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "FILENAME.RULE"));
-    file->filextra = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "FILENAME.XTRA"));
-    file->extrule  = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "EXTNAME.RULE"));
-    file->extxtra  = psMemIncrRefCounter(psMetadataLookupStr (&status, data, "EXTNAME.XTRA"));
-
-    file->fileDepth = depthNameToEnum(psMetadataLookupStr(&status, data, "FILE.DEPTH"));
-    if (file->fileDepth == PM_FPA_DEPTH_NONE) {
-        psError(PS_ERR_IO, true, "FILE.DEPTH is not set for %s\n", name);
-        return NULL;
-    }
-
-    file->dataDepth = depthNameToEnum(psMetadataLookupStr (&status, data, "DATA.DEPTH"));
-    if (file->dataDepth == PM_FPA_DEPTH_NONE) {
-        psError(PS_ERR_IO, true, "DATA.DEPTH is not set for %s\n", name);
-        return NULL;
-    }
-
-    file->type = PM_FPA_FILE_NONE;
-    type = psMetadataLookupStr (&status, data, "FILE.TYPE");
-    if (type != NULL) {
-        if (!strcasecmp (type, "SX"))     {
-            file->type = PM_FPA_FILE_SX;
-        }
-        if (!strcasecmp (type, "OBJ"))     {
-            file->type = PM_FPA_FILE_OBJ;
-        }
-        if (!strcasecmp (type, "CMP"))     {
-            file->type = PM_FPA_FILE_CMP;
-        }
-        if (!strcasecmp (type, "CMF"))     {
-            file->type = PM_FPA_FILE_CMF;
-        }
-        if (!strcasecmp (type, "RAW"))     {
-            file->type = PM_FPA_FILE_RAW;
-        }
-        if (!strcasecmp (type, "IMAGE"))     {
-            file->type = PM_FPA_FILE_IMAGE;
-        }
-        if (!strcasecmp (type, "PSF"))     {
-            file->type = PM_FPA_FILE_PSF;
-        }
-        if (!strcasecmp (type, "JPEG"))     {
-            file->type = PM_FPA_FILE_JPEG;
-        }
-    }
-    if (file->type == PM_FPA_FILE_NONE) {
-        psError(PS_ERR_IO, true, "FILE.TYPE is not defined for %s\n", name);
-        return NULL;
-    }
-
-    file->mode = PM_FPA_MODE_NONE;
-    type = psMetadataLookupStr (&status, data, "FILE.MODE");
-    if (type != NULL) {
-        if (!strcasecmp (type, "READ"))     {
-            file->mode = PM_FPA_MODE_READ;
-        }
-        if (!strcasecmp (type, "WRITE"))     {
-            file->mode = PM_FPA_MODE_WRITE;
-        }
-    }
-    if (file->mode == PM_FPA_MODE_NONE) {
-        psError(PS_ERR_IO, true, "FILE.MODE is not defined for %s\n", name);
-        return NULL;
-    }
-
-    if (fpa != NULL) {
-        file->fpa = psMemIncrRefCounter(fpa);
-    }
-
-    // for WRITE type of data, the output format needs to be determined
-    // this is only needed if the output file is not identical in structure to the input
-    char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT");
-    if (formatName && strcasecmp (formatName, "NONE")) {
-        psMetadata *formats = psMetadataLookupMD(&status, camera, "FORMATS"); // List of formats
-        char *formatFile = psMetadataLookupStr (&status, formats, formatName);
-        if (!formatFile) {
-            psError(PS_ERR_IO, false, "format %s for %s not defined", formatName, name);
-            psFree (file);
-            return NULL;
-        }
-        readConfig (&file->format, formatFile, formatName);
-    }
-
-    psMetadataAddPtr (files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file);
-
-    // we free this copy of file, but 'files' still has a copy
-    psFree (file);
-
-    // the returned value is a view into the version on 'files'
-    return (file);
-}
-
-/*
-pmFPAfile *pmFPAfileConstruct (psMetadata *files, psMetadata *format, psMetadata *camera, char *name)
-{
-    pmFPA *fpa = pmFPAConstruct (camera);
-    pmFPAfile *file = pmFPAfileDefine (files, format, fpa, name);
-    psFree (fpa);
-    if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", name);
-        return NULL;
-    }
-    return file;
-}
-*/
-
-// open file (if not already opened)
-bool pmFPAfileOpen (pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    bool status;
-    char *extra;
-    char *mode = NULL;
-    char *readMode = "r";
-    char *writeMode = "w";
-
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip open for %s, files is inactive", file->name);
-        return true;
-    }
-
-    if (file->state == PM_FPA_STATE_OPEN) {
-        return true;
-    }
-
-    if (file->mode == PM_FPA_MODE_NONE) {
-        psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_NONE");
-        return false;
-    }
-    if (file->mode == PM_FPA_MODE_INTERNAL) {
-        psError(PS_ERR_IO, true, "File is mode PM_FPA_MODE_INTERNAL");
-        return false;
-    }
-    if (file->mode == PM_FPA_MODE_READ) {
-        mode = readMode;
-    }
-    if (file->mode == PM_FPA_MODE_WRITE) {
-        mode = writeMode;
-    }
-
-    // determine the file name
-    // free a name allocated earlier
-    psFree (file->filename);
-    file->filename = pmFPAfileNameFromRule (file->filerule, file, view);
-    if (file->filename == NULL) {
-        psError(PS_ERR_IO, true, "Filename is NULL");
-        return false;
-    }
-
-    // indirect filenames
-    if (!strcasecmp (file->filename, "@FILES")) {
-        psFree (file->filename);
-        extra = pmFPAfileNameFromRule (file->filextra, file, view);
-        file->filename = psMetadataLookupStr (&status, file->names, extra);
-        psFree (extra);
-        if (file->filename == NULL) {
-            psError(PS_ERR_IO, true, "filename lookup error (@FILES) for %s : %s\n", file->filextra, extra);
-            return false;
-        }
-        // psMetadataLookupStr just returns a view, file->filename must be protected
-        psMemIncrRefCounter (file->filename);
-    }
-    if (!strcasecmp (file->filename, "@DETDB")) {
-        psFree (file->filename);
-        extra = pmFPAfileNameFromRule (file->filextra, file, view);
-        // file->filename = pmDetrendSelect (extra);
-        psFree (extra);
-        if (file->filename == NULL) {
-            psError(PS_ERR_IO, true, "filename lookup error (@DETBD) for %s : %s\n", file->filextra, extra);
-            return false;
-        }
-        psMemIncrRefCounter (file->filename);
-    }
-
-    switch (file->type) {
-        // open the FITS types:
-    case PM_FPA_FILE_IMAGE:
-    case PM_FPA_FILE_CMF:
-        psTrace ("pmFPAfile", 5, "opening %s (type: %d)\n", file->filename, file->type);
-        file->fits = psFitsOpen (file->filename, mode);
-        if (file->fits == NULL) {
-            psError(PS_ERR_IO, false, "error opening file %s\n", file->filename);
-            return false;
-        }
-        file->state = PM_FPA_STATE_OPEN;
-        break;
-
-        // defer opening TEXT types:
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_PSF:
-    case PM_FPA_FILE_JPEG:
-        psTrace ("pmFPAfile", 5, "defer opening %s\n", file->filename);
-        break;
-
-    default:
-        psError(PS_ERR_IO, true, "type mismatch for %s : %d\n", file->filename, file->type);
-        return false;
-    }
-    return true;
-}
-
-bool pmFPAfileRead(pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip read for %s, files is inactive", file->name);
-        return true;
-    }
-
-    if (file->mode != PM_FPA_MODE_READ) {
-        psTrace("pmFPAfile", 6, "skip read for %s, mode is not READ", file->name);
-        return true;
-    }
-
-    // get the current depth
-    pmFPAdepth depth = pmFPAviewDepth (view);
-
-    // do we need to open this file?
-    if (depth == file->fileDepth) {
-        if (!pmFPAfileOpen (file, view)) {
-            psError(PS_ERR_IO, false, "failed to open file %s", file->name);
-            return false;
-        }
-    }
-
-    // do we need to read this file?
-    if (depth != file->dataDepth) {
-        psTrace("pmFPAfile", 6, "skip reading of %s at this depth %s: dataDepth is %s",
-                file->name, depthEnumToName(depth), depthEnumToName(file->dataDepth));
-        return true;
-    }
-
-    switch (file->type) {
-    case PM_FPA_FILE_IMAGE:
-        if (pmFPAviewReadFitsImage (view, file)) {
-            psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
-        } else {
-            psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type);
-            return false;
-        }
-        break;
-
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_CMF:
-        pmFPAviewReadObjects (view, file);
-        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
-        break;
-
-    case PM_FPA_FILE_PSF:
-        pmFPAviewReadPSFmodel (view, file);
-        psTrace ("pmFPAfile", 5, "reading %s (type: %d)\n", file->filename, file->type);
-        break;
-
-    case PM_FPA_FILE_JPEG:
-        break;
-
-    default:
-        psError(PS_ERR_IO, true, "warning: type mismatch; saw type %d", file->type);
-        return false;
-    }
-    return true;
-}
-
-bool pmFPAfileFreeData(pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip free for %s, files is inactive", file->name);
-        return true;
-    }
-
-    // get the current depth
-    pmFPAdepth depth = pmFPAviewDepth (view);
-
-    // do we need to read this file?
-    if (depth != file->dataDepth) {
-        psTrace("pmFPAfile", 6, "skip free of %s at this depth %s: dataDepth is %s",
-                file->name, depthEnumToName(depth), depthEnumToName(file->dataDepth));
-        return true;
-    }
-
-    switch (file->type) {
-    case PM_FPA_FILE_IMAGE:
-        if (pmFPAviewFreeFitsImage (view, file)) {
-            psTrace ("pmFPAfile", 5, "freed %s (type: %d)\n", file->filename, file->type);
-        } else {
-            psError(PS_ERR_UNKNOWN, false, "skipping %s (type: %d)\n", file->filename, file->type);
-            return false;
-        }
-        break;
-
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_CMF:
-        // pmFPAviewFreeObjects (view, file);
-        psTrace ("pmFPAfile", 5, "NOT freeing %s (type: %d)\n", file->filename, file->type);
-        break;
-
-        // XXX not certain what I need to free here
-    case PM_FPA_FILE_PSF:
-    case PM_FPA_FILE_JPEG:
-        break;
-
-    default:
-        psError(PS_ERR_IO, true, "warning: type mismatch; saw type %d", file->type);
-        return false;
-    }
-    return true;
-}
-
-bool pmFPAfileWrite(pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip write for %s, files is inactive", file->name);
-        return true;
-    }
-
-    if (file->mode != PM_FPA_MODE_WRITE) {
-        psTrace("pmFPAfile", 6, "skip write for %s, mode is not WRITE", file->name);
-        return true;
-    }
-
-    // get the current depth
-    pmFPAdepth depth = pmFPAviewDepth (view);
-
-    // do we need to write this file?
-    if (depth != file->dataDepth) {
-        psTrace("pmFPAfile", 6, "skip writing of %s at this depth %s: dataDepth is %s",
-                file->name, depthEnumToName(depth), depthEnumToName(file->dataDepth));
-        return true;
-    }
-
-    // do we need to open this file?
-    if (depth >= file->fileDepth) {
-        if (!pmFPAfileOpen (file, view)) {
-            psError(PS_ERR_IO, false, "failed to open %s", file->filename);
-            return false;
-        }
-    }
-
-    switch (file->type) {
-    case PM_FPA_FILE_IMAGE:
-        pmFPAviewWriteFitsImage (view, file);
-        psTrace ("pmFPAfile", 5, "wrote image %s (fpa: %p)\n", file->filename, file->fpa);
-        break;
-
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_CMF:
-        psTrace ("pmFPAfile", 5, "writing object %s (fpa: %p)\n", file->filename, file->fpa);
-        if (!pmFPAviewWriteObjects (view, file)) {
-            psError(PS_ERR_IO, false, "Failed to write object %s", file->filename);
-            return false;
-        }
-
-        break;
-
-    case PM_FPA_FILE_PSF:
-        pmFPAviewWritePSFmodel (view, file);
-        psTrace ("pmFPAfile", 5, "wrote PSF %s (fpa: %p)\n", file->filename, file->fpa);
-        break;
-
-    case PM_FPA_FILE_JPEG:
-        pmFPAviewWriteJPEG (view, file);
-        psTrace ("pmFPAfile", 5, "wrote PSF %s (fpa: %p)\n", file->filename, file->fpa);
-        break;
-
-    default:
-        fprintf (stderr, "warning: type mismatch\n");
-        return false;
-    }
-    return true;
-}
-
-// create the data elements (headers, images) appropriate for this view
-bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    // these are not error conditions; these are state tests
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip create for inactive file %s", file->name);
-        return true;
-    }
-    if (file->mode != PM_FPA_MODE_WRITE) {
-        psTrace("pmFPAfile", 6, "skip create for non-write file %s", file->name);
-        return true;
-    }
-
-    // get the current depth
-    pmFPAdepth depth = pmFPAviewDepth (view);
-
-    // don't create the file if the src FPA is not defined
-    if (file->src == NULL) {
-        psTrace("pmFPAfile", 6, "skip create for FPA without src FPA for %s", file->name);
-        return true;
-    }
-
-    // do we need to write this file?
-    if (depth != file->dataDepth) {
-        psTrace("pmFPAfile", 6, "skip creation of %s at this depth %s: dataDepth is %s",
-                file->name, depthEnumToName(depth), depthEnumToName(file->dataDepth));
-        return true;
-    }
-
-    switch (file->type) {
-    case PM_FPA_FILE_IMAGE:
-        /* create a PHU for thie file, if it does not exist */
-        pmFPAfileCopyStructureView (file->fpa, file->src, file->format, file->xBin, file->yBin, view);
-        psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->name, file->fpa);
-        break;
-
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_CMF:
-    case PM_FPA_FILE_PSF:
-    case PM_FPA_FILE_JPEG:
-        break;
-
-    default:
-        psError(PS_ERR_IO, true, "Unsupported type for %s: %d", file->name, file->type);
-        return false;
-    }
-    return true;
-}
-
-bool pmFPAfileClose (pmFPAfile *file, const pmFPAview *view)
-{
-    PS_ASSERT_PTR_NON_NULL(file, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    if (file->state & PM_FPA_STATE_INACTIVE) {
-        psTrace("pmFPAfile", 6, "skip close for %s, files is inactive", file->name);
-        return true;
-    }
-    if (file->state == PM_FPA_STATE_CLOSED) {
-        return true;
-    }
-
-    // is current depth == open depth?
-    pmFPAdepth depth = pmFPAviewDepth (view);
-    if (file->fileDepth != depth) {
-        psTrace("pmFPAfile", 6, "skip closing of %s at this depth %s: dataDepth is %s",
-                file->name, depthEnumToName(depth), depthEnumToName(file->dataDepth));
-        return true;
-    }
-
-    // check if we are actually open
-    switch (file->type) {
-        // check the FITS types
-    case PM_FPA_FILE_IMAGE:
-    case PM_FPA_FILE_CMF:
-        psFitsClose (file->fits);
-        psTrace ("pmFPAfile", 5, "closing %s (type: %d)\n", file->filename, file->type);
-        file->fits = NULL;
-        file->phu = NULL;
-        file->header = NULL;
-        file->state = PM_FPA_STATE_CLOSED;
-        break;
-
-        // ignore the TEXT types
-    case PM_FPA_FILE_SX:
-    case PM_FPA_FILE_RAW:
-    case PM_FPA_FILE_OBJ:
-    case PM_FPA_FILE_CMP:
-    case PM_FPA_FILE_PSF:
-    case PM_FPA_FILE_JPEG:
-        break;
-
-    default:
-        psError(PS_ERR_IO, true, "type mismatch: %d", file->type);
-        return false;
-    }
-    return true;
-}
-
-// set the state of the specified pmFPAfile to active (state == true) or inactive
-// if name is NULL, set the state for all pmFPAfiles
-bool pmFPAfileActivate (psMetadata *files, bool state, char *name)
-{
-    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 &= 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("pmFPAfile", 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 &= NOT_U8(PM_FPA_STATE_INACTIVE);
-    } else {
-        file->state |= PM_FPA_STATE_INACTIVE;
-    }
-    return true;
-}
-
-// attempt create, read, write, close, or free pmFPAfiles available in files
-// files are automatically opened before they are read
-bool pmFPAfileIOChecks (psMetadata *files, const pmFPAview *view, pmFPAfilePlace place)
-{
-    PS_ASSERT_PTR_NON_NULL(files, false);
-    PS_ASSERT_PTR_NON_NULL(view, false);
-
-    bool status = true;
-
-    // attempt to perform all create, read, write
-    psMetadataItem *item = NULL;
-    psMetadataIterator *iter = psMetadataIteratorAlloc (files, PS_LIST_HEAD, NULL);
-    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
-        pmFPAfile *file = item->data.V;
-
-        switch (place) {
-        case PM_FPA_BEFORE:
-            if (!pmFPAfileRead (file, view)) {
-                psError(PS_ERR_IO, false, "failed READ in FPA_BEFORE block for %s", file->name);
-                status = false;
-            }
-            if (!pmFPAfileCreate(file, view)) {
-                psError(PS_ERR_IO, false, "failed CREATE in FPA_BEFORE block for %s", file->name);
-                status = false;
-            }
-            break;
-        case PM_FPA_AFTER:
-            if (!pmFPAfileWrite (file, view)) {
-                psError(PS_ERR_IO, false, "failed WRITE in FPA_AFTER block for %s", file->name);
-                status = false;
-            }
-            if (!pmFPAfileClose(file, view)) {
-                psError(PS_ERR_IO, false, "failed CLOSE in FPA_AFTER block for %s", file->name);
-                status = false;
-            }
-            break;
-        default:
-            psAbort(PS_FILE_LINE, "You can't get here");
-        }
-    }
-
-    // attempt to free data that is no longer needed
-    psMetadataIteratorSet (iter, PS_LIST_HEAD);
-    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
-        pmFPAfile *file = item->data.V;
-
-        switch (place) {
-        case PM_FPA_BEFORE:
-            break;
-        case PM_FPA_AFTER:
-            if (!pmFPAfileFreeData(file, view)) {
-                psError(PS_ERR_IO, false, "failed FREE in FPA_AFTER block for %s", file->name);
-                status = false;
-            }
-            break;
-        default:
-            psAbort(PS_FILE_LINE, "You can't get here");
-        }
-    }
-    psFree (iter);
-    return status;
-}
-
-// create a file with the given name, assign it type "INTERNAL", and supply it with an image
-// of the requested dimensions. (image only, mask and weight are ignored)
-pmReadout *pmFPAfileCreateInternal (psMetadata *files, char *name, int Nx, int Ny, int type)
-{
-    PS_ASSERT_PTR_NON_NULL(files, false);
-    PS_ASSERT_PTR_NON_NULL(name, false);
-    PS_ASSERT_INT_POSITIVE(strlen(name), false);
-
-    pmReadout *readout = pmReadoutAlloc(NULL);
-    readout->image = psImageAlloc(Nx, Ny, type);
-
-    // I want an image from the
-    pmFPAfile *file = pmFPAfileAlloc();
-    file->mode = PM_FPA_MODE_INTERNAL;
-    file->name = psStringCopy (name);
-
-    file->readout = readout;
-    psMetadataAddPtr(files, PS_LIST_TAIL, name, PS_DATA_UNKNOWN, "", file);
-    psFree(file);
-    // we free this copy of file, but 'files' still has a copy
-
-    return readout;
-}
-
-bool pmFPAfileDropInternal(psMetadata *files, char *name)
-{
-    PS_ASSERT_PTR_NON_NULL(files, false);
-    PS_ASSERT_PTR_NON_NULL(name, false);
-    PS_ASSERT_INT_POSITIVE(strlen(name), false);
-
-    bool status = false;
-
-    pmFPAfile *file = psMetadataLookupPtr (&status, files, name);
-    if (!status) {
-        psTrace("pmFPAfile", 6, "Internal File %s not in file list", name);
-        return true;
-    }
-    if (file == NULL) {
-        psError(PS_ERR_IO, true, "file %s is NULL", name);
-        return false;
-    }
-    if (file->mode != PM_FPA_MODE_INTERNAL) {
-        psTrace("pmFPAfile", 6, "FPA File %s not Internal, not dropping", name);
-        return true;
-    }
-
-    psMetadataRemoveKey (files, name);
-    return true;
-}
-
 // select the readout from the named pmFPAfile; if the named file does not exist,
 pmReadout *pmFPAfileThisReadout (psMetadata *files, const pmFPAview *view, const char *name)
@@ -844,529 +108,5 @@
 }
 
-// given an already-opened fits file, read the components corresponding
-// to the specified view
-bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file)
-{
-    PS_ASSERT_PTR_NON_NULL(view, false);
-    PS_ASSERT_PTR_NON_NULL(file, false);
-
-    bool status;
-    pmFPA *fpa = file->fpa;
-    psFits *fits = file->fits;
-
-    if (view->chip == -1) {
-        status = pmFPARead (fpa, fits, NULL);
-        return status;
-    }
-
-    if (view->chip >= fpa->chips->n) {
-        psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %d", view->chip, fpa->chips->n);
-        return false;
-    }
-    pmChip *chip = fpa->chips->data[view->chip];
-
-    if (view->cell == -1) {
-        status = pmChipRead (chip, fits, NULL);
-        return status;
-    }
-
-    if (view->cell >= chip->cells->n) {
-        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n);
-        return false;
-    }
-    pmCell *cell = chip->cells->data[view->cell];
-
-    if (view->readout == -1) {
-        status = pmCellRead (cell, fits, NULL);
-        return status;
-    }
-    psError(PS_ERR_UNKNOWN, true, "Returning false");
-    return false;
-
-    // XXX pmReadoutRead, pmReadoutReadSegement disabled for now
-    #if 0
-
-    if (view->readout >= cell->readouts->n) {
-        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d",
-                view->readout, cell->readouts->n);
-        return false;
-    }
-    pmReadout *readout = cell->readouts->data[view->readout];
-
-    if (view->nRows == 0) {
-        pmReadoutRead (readout, fits, NULL);
-    } else {
-        pmReadoutReadSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
-    }
-    return true;
-    #endif
-}
-
-// given an already-opened fits file, read the components corresponding
-// to the specified view
-bool pmFPAviewFreeFitsImage (const pmFPAview *view, pmFPAfile *file)
-{
-    PS_ASSERT_PTR_NON_NULL(view, false);
-    PS_ASSERT_PTR_NON_NULL(file, false);
-
-    pmFPA *fpa = file->fpa;
-
-    if (view->chip == -1) {
-        psTrace ("pmFPAfile", 5, "freeing fpa for %s\n", file->filename);
-        psFree (fpa);
-        file->fpa = NULL;
-        return true;
-    }
-
-    if (view->chip >= fpa->chips->n) {
-        psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %d", view->chip, fpa->chips->n);
-        return false;
-    }
-    pmChip *chip = fpa->chips->data[view->chip];
-
-    if (view->cell == -1) {
-        psTrace ("pmFPAfile", 5, "freeing chip %d for %s\n", view->chip, file->filename);
-        psFree (chip);
-        fpa->chips->data[view->chip] = NULL;
-        return true;
-    }
-
-    if (view->cell >= chip->cells->n) {
-        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n);
-        return false;
-    }
-    pmCell *cell = chip->cells->data[view->cell];
-
-    if (view->readout == -1) {
-        psTrace ("pmFPAfile", 5, "freeing cell %d for %s\n", view->cell, file->filename);
-        psFree (cell);
-        chip->cells->data[view->cell] = NULL;
-        return true;
-    }
-    psError(PS_ERR_UNKNOWN, true, "Returning false");
-    return false;
-
-    // XXX pmReadoutRead, pmReadoutReadSegement disabled for now
-    #if 0
-
-    if (view->readout >= cell->readouts->n) {
-        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d",
-                view->readout, cell->readouts->n);
-        return false;
-    }
-    pmReadout *readout = cell->readouts->data[view->readout];
-
-    if (view->nRows == 0) {
-        pmReadoutRead (readout, fits, NULL);
-    } else {
-        pmReadoutReadSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
-    }
-    return true;
-    #endif
-}
-
-// given an already-opened fits file, write the components corresponding
-// to the specified view
-bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file)
-{
-    PS_ASSERT_PTR_NON_NULL(view, false);
-    PS_ASSERT_PTR_NON_NULL(file, false);
-
-    pmFPA *fpa = file->fpa;
-    psFits *fits = file->fits;
-
-    // pmFPAWrite takes care of all PHUs as needed
-    if (view->chip == -1) {
-        pmFPAWrite(fpa, fits, NULL, true, true);
-        return true;
-    }
-
-    if (view->chip >= fpa->chips->n) {
-        psError(PS_ERR_IO, true, "Requested chip == %d >= fpa->chips->n == %d", view->chip, fpa->chips->n);
-        return false;
-    }
-    pmChip *chip = fpa->chips->data[view->chip];
-
-    // do we need to write out a PHU for this entry?
-    if (file->phu == NULL) {
-        pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa);
-        pmHDU *phu = pmFPAviewThisPHU (view, file->fpa);
-        // if this hdu is the phu, the write function below will create the phu
-        if (hdu != phu) {
-            // we assume that the PHU is just a header
-            psMetadata *outhead = psMetadataCopy (NULL, phu->header);
-            psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
-            psFitsWriteBlank (file->fits, outhead);
-            file->phu = phu->header;
-            psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type);
-            psFree (outhead);
-        }
-    }
-
-    if (view->cell == -1) {
-        pmChipWrite (chip, fits, NULL, true, true);
-        return true;
-    }
-
-    if (view->cell >= chip->cells->n) {
-        psError(PS_ERR_IO, true, "Requested cell == %d >= chip->cells->n == %d", view->cell, chip->cells->n);
-        return false;
-    }
-    pmCell *cell = chip->cells->data[view->cell];
-
-    if (view->readout == -1) {
-        return pmCellWrite (cell, fits, NULL, true);
-    }
-    psError(PS_ERR_UNKNOWN, true, "Returning false");
-    return false;
-
-    // XXX disable readout write for now
-    #if 0
-
-    if (view->readout >= cell->readouts->n) {
-        psError(PS_ERR_IO, true, "Requested readout == %d >= cell->readouts->n == %d",
-                view->readout, cell->readouts->n);
-        return false;
-    }
-    pmReadout *readout = cell->readouts->data[view->readout];
-
-    if (view->nRows == 0) {
-        pmReadoutWrite (readout, fits, NULL, NULL);
-    } else {
-        pmReadoutWriteSegment (readout, fits, view->nRows, view->iRows, NULL, NULL);
-    }
-    return true;
-    #endif
-}
-
-// look for the given name on the argument list.
-// returns the file (a view to the one saved on config->files)
-pmFPAfile *pmFPAfileFromArgs (bool *found, pmConfig *config, char *filename, char *argname)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(filename, false);
-    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
-    PS_ASSERT_PTR_NON_NULL(argname, false);
-    PS_ASSERT_INT_POSITIVE(strlen(argname), false);
-
-    bool status;
-    pmFPA *fpa = NULL;
-    psFits *fits = NULL;
-    pmFPAfile *file = NULL;
-    psMetadata *phu = NULL;
-    psMetadata *format = NULL;
-
-    if (*found) {
-        return NULL;
-    }
-
-    // we search the argument data for the named fileset (argname)
-    psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname);
-    if (!status) {
-        psTrace("pmFPAfile", 5, "Failed to find %s in argument list", argname);
-        return NULL;
-    }
-    if (infiles->n < 1) {
-        psError(PS_ERR_IO, false, "Found n == %d files in %s in arguments\n", infiles->n, argname);
-        return NULL;
-    }
-
-    // determine the current format from the header
-    // if no camera has been specified, use the first image as a template for the rest.
-    fits = psFitsOpen (infiles->data[0], "r");
-    phu = psFitsReadHeader (NULL, fits);
-    format = pmConfigCameraFormatFromHeader (config, phu);
-    psFitsClose (fits);                        // don't close phu; we'll use it below
-    if (!format) {
-        psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", infiles->data[0]);
-        psFree(phu);
-        return NULL;
-    }
-
-    // build the template fpa, set up the basic view
-    fpa = pmFPAConstruct (config->camera);
-    if (!fpa) {
-        psError(PS_ERR_IO, false, "Failed to construct FPA from %s", infiles->data[0]);
-        return NULL;
-    }
-
-    // load the given filerule (from config->camera) and associate it with the fpa
-    // the output file is just a view to the file on config->files
-    file = pmFPAfileDefine (config->files, config->camera, fpa, filename);
-    if (!file) {
-        psError(PS_ERR_IO, false, "file %s not defined", filename);
-        psFree(phu);
-        psFree (fpa);
-        psFree (format);
-        return NULL;
-    }
-
-    // this file is (by virtue of being supplied in the argument list) coming from the fileset
-    psFree (file->filerule);
-    psFree (file->filextra);
-
-    // adjust the rules to identify these files in the file->names data
-    file->filerule = psStringCopy ("@FILES");
-    // XXX this rule does not work in general
-    file->filextra = psStringCopy ("{CHIP.NAME}.{CELL.NAME}");
-
-    // examine the list of input files and validate their cameras
-    for (int i = 0; i < infiles->n; i++) {
-        if (i > 0) {
-            fits = psFitsOpen (infiles->data[i], "r");
-            phu = psFitsReadHeader (NULL, fits);
-            pmConfigValidateCameraFormat (format, phu);
-            psFitsClose (fits);
-        }
-
-        // set the view to the corresponding entry for this phu
-        pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);
-        if (!view) {
-            psError(PS_ERR_IO, false, "Failed to set view from file %s", infiles->data[i]);
-            psFree(phu);
-            psFree (fpa);
-            psFree (format);
-            return NULL;
-        }
-
-        // XXX is this the correct psMD to save the filename?
-        char *name = pmFPAfileNameFromRule (file->filextra, file, view);
-        psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
-
-        psFree (view);
-        psFree (name);
-        psFree (phu);
-    }
-    psFree (fpa);
-    psFree (format);
-    *found = true;
-
-    return file;
-}
-
-// XXX this this function through, then finish
-#if 0
-// look for the given name on the argument list.
-// returns the file (a view to the one saved on config->files)
-// in this case, each file should correspond to the same view
-// (except at the readout level), of multiple FPAs
-// XXX think this through a bit more:
-//  - do we create multiple input fpas, or assign the same files to the single fpa?
-//  - do we save the multiple pmFPAfiles in the config->files psMD?
-//  - do we save the multiple filenames in the file->names psMD?
-//  - if we have a single FPA and multiple names, we need a method to
-//    turn on a specific name for the I/O actions.  probably true if we
-//    have multiple FPAs as well.
-pmFPAfile *pmFPAfileSetFromArgs (bool *found, pmConfig *config, char *filename, char *argname)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(filename, false);
-    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
-    PS_ASSERT_PTR_NON_NULL(argname, false);
-    PS_ASSERT_INT_POSITIVE(strlen(argname), false);
-
-    bool status;
-    pmFPA *fpa = NULL;
-    psFits *fits = NULL;
-    pmFPAfile *file = NULL;
-    psMetadata *phu = NULL;
-    psMetadata *format = NULL;
-
-    if (*found)
-        return NULL;
-
-    // we search the argument data for the named fileset (argname)
-    psArray *infiles = psMetadataLookupPtr(&status, config->arguments, argname);
-    if (!status) {
-        return NULL;
-    }
-    if (infiles->n < 1) {
-        return NULL;
-    }
-
-    // determine the current format from the header
-    // if no camera has been specified, use the first image as a template for the rest.
-    fits = psFitsOpen (infiles->data[0], "r");
-    phu = psFitsReadHeader (NULL, fits);
-    format = pmConfigCameraFormatFromHeader (config, phu);
-    psFitsClose (fits);
-
-    // build the template fpa, set up the basic view
-    fpa = pmFPAConstruct (config->camera);
-
-    // load the given filerule (from config->camera) and associate it with the fpa
-    // the output file is just a view to the file on config->files
-    // XXX the filenames placed on config->files should include the seq number
-    file = pmFPAfileDefine (config->files, config->camera, fpa, filename);
-    if (!file) {
-        psError(PS_ERR_IO, false, "file %s not defined", filename);
-        psFree (fpa);
-        psFree (format);
-        return NULL;
-    }
-
-    // this file is (by virtue of being supplied in the argument list) coming from the fileset
-    psFree (file->filerule);
-    psFree (file->filextra);
-
-    // adjust the rules to identify these files in the file->names data
-    file->filerule = psStringCopy ("@FILES");
-    // XXX this rule does not work in general
-    file->filextra = psStringCopy ("{CHIP.NAME}.{CELL.NAME}");
-
-    // examine the list of input files and validate their cameras
-    for (int i = 0; i < infiles->n; i++) {
-        if (i > 0) {
-            fits = psFitsOpen (infiles->data[i], "r");
-            phu = psFitsReadHeader (NULL, fits);
-            pmConfigValidateCameraFormat (format, phu);
-            psFitsClose (fits);
-        }
-
-        // set the view to the corresponding entry for this phu
-        pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);
-
-        // XXX is this the correct psMD to save the filename?
-        char *name = pmFPAfileNameFromRule (file->filextra, file, view);
-        psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
-
-        psFree (view);
-        psFree (name);
-        psFree (phu);
-    }
-    psFree (fpa);
-    psFree (format);
-    *found = true;
-
-    return file;
-}
-#endif
-
-// create a new output pmFPAfile based on an existing FPA
-pmFPAfile *pmFPAfileFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, char *filename)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(src, false);
-    PS_ASSERT_PTR_NON_NULL(filename, false);
-    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
-
-    // XXX pmFPAConstruct has many leaks (6919)
-    pmFPA *fpa = pmFPAConstruct (config->camera);
-    pmFPAfile *file = pmFPAfileDefine (config->files, config->camera, fpa, filename);
-    if (!file) {
-        psErrorStackPrint(stderr, "file %s not defined\n", filename);
-        return NULL;
-    }
-    file->src = src; // inherit output elements from this source pmFPA
-    file->xBin = xBin;
-    file->yBin = yBin;
-
-    psFree (fpa);
-    return file;
-}
-
-// look for the given name on the argument list.
-pmFPAfile *pmFPAfileFromConf (bool *found, pmConfig *config, char *filename, pmFPA *input)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-    PS_ASSERT_PTR_NON_NULL(filename, false);
-    PS_ASSERT_INT_POSITIVE(strlen(filename), false);
-    PS_ASSERT_PTR_NON_NULL(input, false);
-
-    psFits *fits = NULL;
-    pmFPAfile *file = NULL;
-    psMetadata *phu = NULL;
-    psMetadata *format = NULL;
-    psArray *infiles = NULL;
-
-    if (*found) {
-        return NULL;
-    }
-
-    // a camera config is needed (as source of file rule)
-    if (config->camera == NULL) {
-        psErrorStackPrint (stderr, "camera is not defined\n");
-        return NULL;
-    }
-
-    // expect @DETDB in the config filerule
-    file = pmFPAfileDefine (config->files, config->camera, NULL, filename);
-    if (!file) {
-        psError(PS_ERR_IO, false, "file %s not defined\n", filename);
-        return NULL;
-    }
-
-    // image names come from the file->name list?
-    if (!strcasecmp (file->filerule, "@FILES")) {
-        psAbort ("pmFPAfileFromConfig", "programming error");
-    }
-
-    // image needs to come from the detrend database
-    if (!strcasecmp (file->filerule, "@DETDB")) {
-        // char *extra = pmFPAfileNameFromRule (file->filextra, file, view);
-        // psArray *infiles = pmDetrendSelect (extra, input);
-        psAbort ("pmFPAfileFromConfig", "programming error: @DETDB not yet defined");
-    } else {
-        infiles = psArrayAlloc(1);
-        infiles->n = 1;
-        infiles->data[0] = psStringCopy (file->filerule);
-    }
-    if (infiles == NULL) {
-        return NULL;
-    }
-    if (infiles->n < 1) {
-        psFree (infiles);
-        return NULL;
-    }
-
-    // determine the current format from the header
-    // if no camera has been specified, use the first image as a template for the rest.
-    fits = psFitsOpen (infiles->data[0], "r");
-    phu = psFitsReadHeader (NULL, fits);
-    format = pmConfigCameraFormatFromHeader (config, phu);
-    psFitsClose (fits);
-
-    // build the template fpa, set up the basic view
-    file->fpa = pmFPAConstruct (config->camera);
-
-    // this file is (by virtue of being supplied in the argument list) coming from the fileset
-    psFree (file->filerule);
-    psFree (file->filextra);
-
-    // adjust the rules to identify these files in the file->names data
-    file->filerule = psStringCopy ("@FILES");
-    // XXX this rule does not work in general
-    file->filextra = psStringCopy ("{CHIP.NAME}.{CELL.NAME}");
-
-    // examine the list of input files and validate their cameras
-    for (int i = 0; i < infiles->n; i++) {
-        if (i > 0) {
-            fits = psFitsOpen (infiles->data[i], "r");
-            phu = psFitsReadHeader (NULL, fits);
-            pmConfigValidateCameraFormat (format, phu);
-            psFitsClose (fits);
-        }
-
-        // set the view to the corresponding entry for this phu
-        pmFPAview *view = pmFPAAddSourceFromHeader (file->fpa, phu, format);
-        if (!view) {
-            psError(PS_ERR_IO, false, "Unable to determine source for %s", file->name);
-            return NULL;
-        }
-
-        // XXX is this the correct psMD to save the filename?
-        char *name = pmFPAfileNameFromRule (file->filextra, file, view);
-        psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]);
-
-        psFree (view);
-        psFree (name);
-        psFree (phu);
-    }
-    psFree (format);
-    psFree (infiles);
-    *found = true;
-    return file;
-}
-
+// XXX reconsider this function name / concept
 bool pmFPAfileAddFileNames (psMetadata *files, char *name, char *value, int mode)
 {
