TXmlStorage::~TXmlStorage() { if (GetAccessMode() == smReadWrite) { WriteXml(); } SAFE_DESTROY_EX(tinyxml2::XMLDocument, FXmlDoc); }
void TRegistryStorage::SetAccessMode(TStorageAccessMode Value) { THierarchicalStorage::SetAccessMode(Value); if (FRegistry) { switch (GetAccessMode()) { case smRead: FRegistry->SetAccess(KEY_READ); break; case smReadWrite: default: FRegistry->SetAccess(KEY_READ | KEY_WRITE); break; } } }
void TXmlStorage::SetAccessMode(TStorageAccessMode Value) { THierarchicalStorage::SetAccessMode(Value); switch (GetAccessMode()) { case smRead: ReadXml(); break; case smReadWrite: default: FXmlDoc->LinkEndChild(FXmlDoc->NewDeclaration()); DebugAssert(FCurrentElement == nullptr); FCurrentElement = FXmlDoc->NewElement(CONST_ROOT_NODE); FCurrentElement->SetAttribute(CONST_VERSION_ATTR, CONST_XML_VERSION21); FXmlDoc->LinkEndChild(FCurrentElement); break; } }
HRESULT __stdcall Stat(STATSTG* stat, DWORD grfStatFlag) { if(!stat) return E_INVALIDARG; switch(grfStatFlag) { case STATFLAG_DEFAULT: str::clear(stat->pwcsName); break; default: stat->pwcsName = NULL; break; } FILETIME time; CoFileTimeNow(&time); stat->type = STGTY_STREAM; stat->cbSize.QuadPart = GetSize(); stat->grfMode = GetAccessMode(); stat->grfLocksSupported = 0; stat->clsid = GUID_NULL; stat->mtime = stat->ctime = stat->atime = time; return S_OK; }