Index: trunk/archive/scripts/src/phase2/pmFPAWrite.c
===================================================================
--- trunk/archive/scripts/src/phase2/pmFPAWrite.c	(revision 5786)
+++ trunk/archive/scripts/src/phase2/pmFPAWrite.c	(revision 5789)
@@ -124,17 +124,6 @@
                     if (strcasecmp(sourceType, "FILE") == 0) {
                         // Source is a file (with optional extension, e.g., "myMaskFile.fits:thisExt"
-                        psString filenameExt = p_pmFPATranslateName(name, cell);
-                        char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
-                        psString filename = NULL; // The filename
-                        psString extname = NULL;// The extenstion name
-                        if (colon) {
-                            filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
-                            if (strlen(colon) > 1) {
-                                extname = psStringCopy(colon + 1);
-                            }
-                        } else {
-                            filename = psMemIncrRefCounter(filenameExt);
-                        }
-
+                        psString extname = NULL; // Extension name
+                        psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename
                         psFree(maskDest);
                         maskDest = psFitsOpen(filename, "rw");
@@ -144,5 +133,4 @@
                         psFree(filename);
                         psFree(extname);
-                        psFree(filenameExt);
                     } else if (strncasecmp(sourceType, "EXT", 3) == 0) {
                         // Source is an extension in the original file
@@ -227,16 +215,6 @@
                     if (strcasecmp(sourceType, "FILE") == 0) {
                         // Source is a file (with optional extension, e.g., "myWeightFile.fits:thisExt"
-                        psString filenameExt = p_pmFPATranslateName(name, cell);
-                        char *colon = strchr(filenameExt, ':'); // Pointer to a colon in the filename-extn
-                        psString filename = NULL; // The filename
-                        psString extname = NULL;// The extenstion name
-                        if (colon) {
-                            filename = psStringNCopy(filenameExt, strlen(filenameExt) - strlen(colon));
-                            if (strlen(colon) > 1) {
-                                extname = psStringCopy(colon + 1);
-                            }
-                        } else {
-                            filename = psMemIncrRefCounter(filenameExt);
-                        }
+                        psString extname = NULL; // Extension name
+                        psString filename = p_pmFPATranslateFileExt(&extname, name, cell); // The filename
 
                         psFree(weightDest);
@@ -247,5 +225,4 @@
                         psFree(filename);
                         psFree(extname);
-                        psFree(filenameExt);
                     } else if (strncasecmp(sourceType, "EXT", 3) == 0) {
                         // Source is an extension in the original file
