THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/07/2006 at 22:26, xxxxxxxx wrote:
Always store the number of elements of the cached array in a Resource description. If it's 0, then nothing to load from file and move on. If it's not 0, allocate and fill the cached array:
// NodeData.Read - Read data from HyperFile
//*---------------------------------------------------------------------------*
Bool IPPBase::Read(GeListNode* node, HyperFile* hf, LONG level)
//*---------------------------------------------------------------------------*
{
BaseContainer* bc = ((BaseObject* )node)->GetDataInstance();
if (level >= 0)
{
LONG size;
if (size = bc->GetLong(AVM_COMPRESS))
{
avmapC = (Bytef* )GeAlloc(sizeof(Bytef)*size);
if (!avmapC) return ErrorException::Throw(EE_DIALOG, GeLoadString(IPPERR_MEMORY_TEXT), "IPPBase.Read.avmap");
hf->ReadMemory((void** )&avmapC;, &size;);
}
return TRUE;
}
// NodeData.Write - Write data to HyperFile
//*---------------------------------------------------------------------------*
Bool IPPBase::Write(GeListNode* node, HyperFile* hf)
//*---------------------------------------------------------------------------*
{
BaseContainer* bc = ((BaseObject* )node)->GetDataInstance();
if (!bc) return FALSE;
// Level 0
if (avmapC) hf->WriteMemory(avmapC, sizeof(Bytef)*bc->GetLong(AVM_COMPRESS));
// Level 1
return TRUE;
}
// NodeData.Copy - Copy data to copied PluginTag
//*---------------------------------------------------------------------------*
Bool IPPBase::CopyTo(NodeData* dest, GeListNode* snode, GeListNode* dnode, LONG flags, AliasTrans* trn)
//*---------------------------------------------------------------------------*
{
BaseContainer* sbc = ((BaseObject* )snode)->GetDataInstance();
if (!sbc) return FALSE;
LONG size;
IPPBase* base = (IPPBase* )dest;
if (!base) return FALSE;
if (avmapC)
{
size = sizeof(Bytef)*sbc->GetLong(AVM_COMPRESS);
if (!size) return FALSE;
base->avmapC = (Bytef* )GeAlloc(size);
if (!base->avmapC) return ErrorException::Throw(EE_DIALOG, GeLoadString(IPPERR_MEMORY_TEXT), "IPPBase.CopyTo.base->avmap");
CopyMem(avmapC, base->avmapC, size);
}
return TRUE;
}