20030519 release
[uzi.git] / src / mkfont / hyfile.cpp
index f39efc3..df8e2e0 100644 (file)
@@ -51,29 +51,6 @@ int fiFileFree(FILETAG *pft)
 \r
 // ----------------------------------------------------------------------------\r
 \r
-int fiFileWriteOut(FILETAG *pft, char *pszName)\r
-     {\r
-     int iSize;\r
-     FSHANDLE fsh;\r
-\r
-     // attempt to create or truncate file for writing\r
-     if (fiFSCreate(&fsh, pszName) == FALSE)\r
-          {\r
-          return FALSE; // probably directory not found\r
-          }\r
-\r
-     // attempt to write the exact amount of data\r
-     iSize = iFileSize(pft);\r
-     if (iFSWrite(&fsh, pft->pcBase, iSize) != iSize)\r
-          {\r
-          fiFSClose(&fsh);\r
-          return FALSE;\r
-          }\r
-\r
-     fiFSClose(&fsh);\r
-     return TRUE; // says we wrote the file\r
-     }\r
-\r
 int fiFileReadIn(FILETAG *pft, char *pszName)\r
      {\r
      int iSize;\r
@@ -124,6 +101,29 @@ int fiFileReadIn(FILETAG *pft, char *pszName)
      return TRUE; // says we read the file\r
      }\r
 \r
+int fiFileWriteOut(FILETAG *pft, char *pszName)\r
+     {\r
+     int iSize;\r
+     FSHANDLE fsh;\r
+\r
+     // attempt to create or truncate file for writing\r
+     if (fiFSCreate(&fsh, pszName) == FALSE)\r
+          {\r
+          return FALSE; // probably directory not found\r
+          }\r
+\r
+     // attempt to write the exact amount of data\r
+     iSize = iFileSize(pft);\r
+     if (iFSWrite(&fsh, pft->pcBase, iSize) != iSize)\r
+          {\r
+          fiFSClose(&fsh);\r
+          return FALSE;\r
+          }\r
+\r
+     fiFSClose(&fsh);\r
+     return TRUE; // says we wrote the file\r
+     }\r
+\r
 // ----------------------------------------------------------------------------\r
 \r
 int fiFileCopy(FILETAG *pft, FILETAG *pftIn)\r
@@ -145,7 +145,7 @@ int fiFileCopy(FILETAG *pft, FILETAG *pftIn)
      i = pft->pcBase - pftIn->pcBase;\r
 \r
      // copy the entire file tag item data area, avoiding leaks\r
-     memcpy(pft, pftIn, iSize);\r
+     memcpy(pft, pftIn, sizeof(FILETAG));\r
 \r
      // apply the required adjustment to all fields of filetag\r
      pft->pcBase += i;\r
@@ -155,6 +155,10 @@ int fiFileCopy(FILETAG *pft, FILETAG *pftIn)
 \r
      // another slight adjustment because the copy trims to size\r
      pft->pcLimit = pft->pcAppend;\r
+\r
+     // copy the data area attached to the input file tag\r
+     memcpy(pft->pcBase, pftIn->pcBase, iSize);\r
+\r
      return TRUE; // indicates copied and new tag item filled out\r
      }\r
 \r
@@ -198,38 +202,6 @@ int fiFileCopyPadded(FILETAG *pft, FILETAG *pftIn, int iLeft, int iRight)
 \r
 // ----------------------------------------------------------------------------\r
 \r
-int fiFilePutLine(FILETAG *pft, char *pszLine)\r
-     {\r
-     int iTemp;\r
-\r
-     // calculate length once\r
-     iTemp = 0;\r
-     if (pszLine != NULL)\r
-          {\r
-          iTemp = strlen(pszLine);\r
-          }\r
-\r
-     // do not go past end of memory\r
-     if ((pft->pcPosition + iTemp + 2) > pft->pcLimit)\r
-          {\r
-          return FALSE;\r
-          }\r
-\r
-     // copy line and crlf terminator out to heap\r
-     if (pszLine != NULL)\r
-          {\r
-          memcpy(pft->pcPosition, pszLine, iTemp);\r
-          }\r
-     memcpy(pft->pcPosition + iTemp, "\r\n", 2);\r
-     pft->pcPosition += iTemp + 2;\r
-\r
-     // set file length possibly truncating\r
-     pft->pcAppend = pft->pcPosition;\r
-\r
-     // say we stored a line\r
-     return TRUE;\r
-     }\r
-\r
 int fiFileGetLine(FILETAG *pft, char *pszLine, int iLimit, int *piCount)\r
      {\r
      int i;\r
@@ -303,5 +275,37 @@ int fiFileGetLine(FILETAG *pft, char *pszLine, int iLimit, int *piCount)
      return TRUE;\r
      }\r
 \r
+int fiFilePutLine(FILETAG *pft, char *pszLine)\r
+     {\r
+     int iTemp;\r
+\r
+     // calculate length once\r
+     iTemp = 0;\r
+     if (pszLine != NULL)\r
+          {\r
+          iTemp = strlen(pszLine);\r
+          }\r
+\r
+     // do not go past end of memory\r
+     if ((pft->pcPosition + iTemp + 2) > pft->pcLimit)\r
+          {\r
+          return FALSE;\r
+          }\r
+\r
+     // copy line and crlf terminator out to heap\r
+     if (pszLine != NULL)\r
+          {\r
+          memcpy(pft->pcPosition, pszLine, iTemp);\r
+          }\r
+     memcpy(pft->pcPosition + iTemp, "\r\n", 2);\r
+     pft->pcPosition += iTemp + 2;\r
+\r
+     // set file length possibly truncating\r
+     pft->pcAppend = pft->pcPosition;\r
+\r
+     // say we stored a line\r
+     return TRUE;\r
+     }\r
+\r
 // ----------------------------------------------------------------------------\r
 \r