HyperFile
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/07/2006 at 20:27, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.1
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;---------
Hi all,i need help about Hyperfile.
I need to save a cached array in hyperfile. All work good when i save a scene to disk with a filled cache, write and read work like a charm.. but when i save a document to disk without a cached data and i load the file, the Read expect someting to get in hyperfile and i get error (Incorrect file structure).
How i know if there is the cached data (Vector array) so i can prevento to load anything and get error?Thanks in advance
Renato T. -
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; }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/07/2006 at 22:37, xxxxxxxx wrote:
Thanks Robert, like ever
I made another thing for now.
I have a Hidden flag in my container that is TRUE when cached if filled.So in read i check for this flag and if TRUE i load data from HyperFile.
seem to be ok.. just testing.
What do you think?Cheers
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/07/2006 at 00:17, xxxxxxxx wrote:
Is the cache array always the same size? If yes, a flag is good enough to indicate its presence or absence. If no (as in most of my cases), then best to use the array size as an indicator and allocator.
If it works, great!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/07/2006 at 00:20, xxxxxxxx wrote:
when i wrote a scene the cached lenght of array is the same that i'll load ...
it sound a bit dangerous to me.. but i'm making test and seem working
what's the way to get the size of an array?
my best regards
Renato -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/07/2006 at 01:06, xxxxxxxx wrote:
You have to know. Either you store the array size as bytes or the number of elements in the array and then calculate the bytesize from (number of elements)*(bytesize of element).
I usually store the number of elements (as a LONG) at the same time that the array is allocated. This is why I always store it in a description - descriptions are always read before Read() is called in your plugin. Now, you could also Write() the value/flag in the hyperfile before you write the array, if necessary. But best to reserve Read/Write/CopyTo for things that cannot be represented in the Description BaseContainer. Make sure to initialize the number-of-element description to 0 in Init().
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/07/2006 at 02:58, xxxxxxxx wrote:
Yes, i see
Thanks Robert
Renato T.