LPDATAFILETREE vmsDataFile::CreateSection(LPCSTR pszSection, LPDATAFILETREE ptRoot) { if (ptRoot == NULL) ptRoot = m_tData; if (pszSection == NULL || *pszSection == 0) return ptRoot; fsString strS; while (*pszSection && *pszSection != '\\' && *pszSection != '/') strS += *pszSection++; if (*pszSection) pszSection++; if (strS != "") for (int i = 0; i < ptRoot->GetLeafCount (); i++) { LPDATAFILETREE ptLeaf = ptRoot->GetLeaf (i); if (ptLeaf->GetData ().vt.empty () && ptLeaf->GetData ().strName == strS) return CreateSection (pszSection, ptLeaf); } LPDATAFILETREE ptLeaf = ptRoot->AddLeaf (vmsDataFileItem ()); ptLeaf->GetData ().strName = strS; return CreateSection (pszSection, ptLeaf); }
LPDATAFILEITEM vmsDataFile::CreateItem(LPDATAFILETREE pSection, LPCSTR pszItemName) { LPDATAFILETREE ptLeaf = FindItem (NULL, pszItemName, pSection); if (ptLeaf == NULL) { ptLeaf = pSection->AddLeaf (vmsDataFileItem ()); ptLeaf->GetData ().strName = pszItemName; } return &ptLeaf->GetData ().vt; }
void vmsDataFile::LoadFromFile(vmsFile &file, LPDATAFILETREE ptRoot) { ASSERT (ptRoot != NULL); LoadFromFile (file, ptRoot->GetData ()); if (ptRoot->GetData ().vt.empty () == false) return; int cLeafs; file.ReadInt (cLeafs); for (int i = 0; i < cLeafs; i++) LoadFromFile (file, ptRoot->AddLeaf (vmsDataFileItem ())); }
bool vmsDataFile::LoadFromBuffer(LPBYTE& pbtCurrentPos, LPBYTE pbtBuffer, DWORD dwBufferSizeSize, LPDATAFILETREE ptRoot) { ASSERT (ptRoot != NULL); if (!LoadFromBuffer (pbtCurrentPos, pbtBuffer, dwBufferSizeSize, ptRoot->GetData ())) return false; if (ptRoot->GetData ().vt.empty () == false) { return true; } int cLeafs; if (!getVarFromBuffer(cLeafs, pbtCurrentPos, pbtBuffer, dwBufferSizeSize)) return false; for (int i = 0; i < cLeafs; i++) { if (!LoadFromBuffer (pbtCurrentPos, pbtBuffer, dwBufferSizeSize, ptRoot->AddLeaf (vmsDataFileItem ()))) return false; } return true; }