Index: trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO.c	(revision 9560)
+++ trunk/psModules/src/objects/pmSourceIO.c	(revision 10421)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2006-10-14 00:53:56 $
+ *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2006-12-03 18:48:10 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -60,5 +60,5 @@
 
 // Given a FITS file pointer, write the table of object data
-bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file)
+bool pmFPAviewWriteObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
@@ -66,5 +66,5 @@
 
     if (view->chip == -1) {
-        if (!pmFPAWriteObjects (fpa, view, file)) {
+        if (!pmFPAWriteObjects (fpa, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write objects from fpa");
             return false;
@@ -80,5 +80,5 @@
 
     if (view->cell == -1) {
-        if (!pmChipWriteObjects (chip, view, file)) {
+        if (!pmChipWriteObjects (chip, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write objects from chip");
             return false;
@@ -95,5 +95,5 @@
 
     if (view->readout == -1) {
-        if (!pmCellWriteObjects (cell, view, file)) {
+        if (!pmCellWriteObjects (cell, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write objects from cell");
             return false;
@@ -110,5 +110,5 @@
     pmReadout *readout = cell->readouts->data[view->readout];
 
-    if (!pmReadoutWriteObjects (readout, view, file)) {
+    if (!pmReadoutWriteObjects (readout, view, file, config)) {
         psError(PS_ERR_IO, false, "Failed to write objects from readout %d", view->readout);
         return false;
@@ -119,5 +119,5 @@
 
 // read in all chip-level Objects files for this FPA
-bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
+bool pmFPAWriteObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
@@ -125,5 +125,5 @@
 
         pmChip *chip = fpa->chips->data[i];
-        if (!pmChipWriteObjects (chip, view, file)) {
+        if (!pmChipWriteObjects (chip, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write %dth chip", i);
             return false;
@@ -134,5 +134,5 @@
 
 // read in all cell-level Objects files for this chip
-bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
+bool pmChipWriteObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
@@ -140,5 +140,5 @@
 
         pmCell *cell = chip->cells->data[i];
-        if (!pmCellWriteObjects (cell, view, file)) {
+        if (!pmCellWriteObjects (cell, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write %dth cell", i);
             return false;
@@ -149,5 +149,5 @@
 
 // read in all readout-level Objects files for this cell
-bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
+bool pmCellWriteObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
@@ -155,5 +155,5 @@
 
         pmReadout *readout = cell->readouts->data[i];
-        if (!pmReadoutWriteObjects (readout, view, file)) {
+        if (!pmReadoutWriteObjects (readout, view, file, config)) {
             psError(PS_ERR_IO, false, "Failed to write %dth readout", i);
             return false;
@@ -164,8 +164,9 @@
 
 // read in all readout-level Objects files for this cell
-bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
+bool pmReadoutWriteObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
     bool status;
+    char *realname;
     char *filename;
     char *dataname;
@@ -183,5 +184,7 @@
     case PM_FPA_FILE_RAW:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        pmSourcesWriteRAW (sources, filename);
+        realname = pmConfigConvertFilename (filename, config);
+        pmSourcesWriteRAW (sources, realname);
+        psFree (realname);
         psFree (filename);
         break;
@@ -189,5 +192,7 @@
     case PM_FPA_FILE_OBJ:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        pmSourcesWriteOBJ (sources, filename);
+        realname = pmConfigConvertFilename (filename, config);
+        pmSourcesWriteOBJ (sources, realname);
+        psFree (realname);
         psFree (filename);
         break;
@@ -195,5 +200,7 @@
     case PM_FPA_FILE_SX:
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
-        pmSourcesWriteSX (sources, filename);
+        realname = pmConfigConvertFilename (filename, config);
+        pmSourcesWriteSX (sources, realname);
+        psFree (realname);
         psFree (filename);
         break;
@@ -203,4 +210,5 @@
         hdu = pmFPAviewThisHDU (view, file->fpa);
         filename = pmFPAfileNameFromRule (file->filerule, file, view);
+        realname = pmConfigConvertFilename (filename, config);
 
         // copy the header to an output header, add the output header data
@@ -219,6 +227,7 @@
         }
 
-        bool status = pmSourcesWriteCMP (sources, filename, outhead);
+        bool status = pmSourcesWriteCMP (sources, realname, outhead);
         psFree (outhead);
+        psFree (realname);
         psFree (filename);
 
@@ -310,10 +319,10 @@
 
 // Given a FITS file pointer, read the table of object data
-bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file)
+bool pmFPAviewReadObjects (const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     pmFPA *fpa = file->fpa;
 
     if (view->chip == -1) {
-        pmFPAReadObjects (fpa, view, file);
+        pmFPAReadObjects (fpa, view, file, config);
         return true;
     }
@@ -325,5 +334,5 @@
 
     if (view->cell == -1) {
-        pmChipReadObjects (chip, view, file);
+        pmChipReadObjects (chip, view, file, config);
         return true;
     }
@@ -335,5 +344,5 @@
 
     if (view->readout == -1) {
-        pmCellReadObjects (cell, view, file);
+        pmCellReadObjects (cell, view, file, config);
         return true;
     }
@@ -344,14 +353,14 @@
     pmReadout *readout = cell->readouts->data[view->readout];
 
-    pmReadoutReadObjects (readout, view, file);
+    pmReadoutReadObjects (readout, view, file, config);
     return true;
 }
 
 // read in all chip-level Objects files for this FPA
-bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file)
+bool pmFPAReadObjects (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     for (int i = 0; i < fpa->chips->n; i++) {
         pmChip *chip = fpa->chips->data[i];
-        pmChipReadObjects (chip, view, file);
+        pmChipReadObjects (chip, view, file, config);
     }
     return true;
@@ -359,9 +368,9 @@
 
 // read in all cell-level Objects files for this chip
-bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file)
+bool pmChipReadObjects (pmChip *chip, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     for (int i = 0; i < chip->cells->n; i++) {
         pmCell *cell = chip->cells->data[i];
-        pmCellReadObjects (cell, view, file);
+        pmCellReadObjects (cell, view, file, config);
     }
     return true;
@@ -369,5 +378,5 @@
 
 // read in all readout-level Objects files for this cell
-bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file)
+bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
     // determine the number of readouts:
@@ -384,5 +393,5 @@
     for (int i = 0; i < cell->readouts->n; i++) {
         pmReadout *readout = cell->readouts->data[i];
-        pmReadoutReadObjects (readout, view, file);
+        pmReadoutReadObjects (readout, view, file, config);
         cell->data_exists = true;
     }
@@ -391,5 +400,5 @@
 
 // read in all readout-level Objects files for this cell
-bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file)
+bool pmReadoutReadObjects (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
 
@@ -427,5 +436,8 @@
             psMemIncrRefCounter (file->filename);
         }
-        file->fits = psFitsOpen (file->filename, "r");
+
+        psString realname = pmConfigConvertFilename (file->filename, config);
+
+        file->fits = psFitsOpen (realname, "r");
         if (hdu->header != NULL) {
             psFree (hdu->header);
@@ -435,5 +447,6 @@
         file->fits = NULL;
 
-        sources = pmSourcesReadCMP (file->filename, hdu->header);
+        sources = pmSourcesReadCMP (realname, hdu->header);
+        psFree (realname);
         break;
 
