Is there a difference in the way ExgDBRead() operates, compared to
DmCreateDatabaseFromImage()? I make the following calls, and the
first method results in a corrupt database, and the second method
gives me a good one. By corrupt, I mean that the DmGetRecord(db,0)
returns the wrong data:
readInfo->done = false;
readInfo->accum = MemPtrNew( contentLen );
// <assume the accum field gets the right data>
readInfo->ptr = readInfo->accum;
err = ExgDBRead( (ExgDBReadProcPtr) read_proc
(ExgDBDeleteProcPtr) delete_proc,
readInfo, &dbID, 0, &needReset, true);
err = DmCreateDatabaseFromImage( readInfo->accum );
In both cases, I'm using the same data in the same in-memory buffer.
Here is my callback routine, and the structure that gets passed to the
userDataP param:
Err read_proc( void *dataP, UInt32 *sizeP, void *userDataP )
{
read_info *rinfo = (read_info*) userDataP;
UInt16 readCount;
int err = 0;
if( rinfo->done ) {
*sizeP = 0;
return errNone;
}
if( rinfo->expected > 0 ) {
readCount = rinfo->expected;
if( readCount > *sizeP )
readCount = *sizeP;
MemMove( dataP, rinfo->ptr, readCount );
rinfo->ptr += readCount;
rinfo->expected -= readCount;
if( rinfo->expected <= 0 )
rinfo->done = true;
}
return errNone;
}
typedef struct read_info {
UInt16 expected;
char *accum;
char *ptr;
Boolean done;
} read_info;
The callback is pre-dictable, reading the DB header fields first, then
the record data. Everything completes without error. The generated
databases appear when they are enumerated by
DmGetNextDatabaseByTypeCreator(), but when I go to get the data from
it, it's just wrong.
Please tell me I've got a mistake in the way I'm using ExgDBRead()!
Thanks,
Jim
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/