\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
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
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
\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
\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
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