Bool AppendString(CDynamicArray<char>& arLine, CDynamicArray<char>& arTempString, const String &str) { char *pchTemp; Int32 lLen = str.GetCStringLen(STRINGENCODING_7BITHEX); if (!arLine.Append('\"')) return false; if (!arTempString.SetMinSizeNoCopy(3 + lLen)) return false; pchTemp = arTempString.GetArray(); str.GetCString(pchTemp, lLen + 1, STRINGENCODING_7BITHEX); if (!AppendString(arLine, pchTemp)) return false; if (!arLine.Append('\"')) return false; return true; }
Bool AppendString(CDynamicArray<char>& arLine, const char* pchLine) { while (*pchLine != '\0') { if (*pchLine == '\"') { if (!arLine.Append('\"') || !arLine.Append('\"')) return false; } else { if (!arLine.Append(*pchLine)) return false; } pchLine++; } return true; }
Bool ReadLine(BaseFile* pFile, CDynamicArray<char>& arLine) { if (pFile->GetPosition() >= pFile->GetLength()) return false; char ch; Bool bEmpty, bEOF = false; // read line do { arLine.ResetCounter(); while (!bEOF) { if (!pFile->TryReadBytes(&ch, 1)) { if (!arLine.Append('\0')) return false; bEOF = true; } else if (ch == '\r' || ch == '\n') { if (!arLine.Append('\0')) return false; break; } else { if (!arLine.Append(ch)) return false; } } bEmpty = (arLine.GetElementCount() == 0); if (!bEmpty && arLine[0] == '\0') bEmpty = true; } while (bEmpty && !bEOF); return true; }