|
|
 | | From: | Alex | | Subject: | Update Resources in DB | | Date: | Thu, 25 Nov 2004 10:12:45 -0000 |
|
|
 | Hi guyz,
I am trying to run an update on a resource database. There don't seem to be such a thing as updating, but more of a delete/add resource...
So here is the code :
resIndex = DmFindResourceType (updDB, 'type', idx); while (resIndex != 0xFFFF) { err = DmResourceInfo (updDB, resIndex, NULL, &id, NULL); // get the id
newH = DmGetResourceIndex (updDB, resIndex); // get the handle oldIndex = DmFindResource (bookDB, 'type', id, NULL); // find the old index if (oldIndex != 0xFFFF) { err = DmRemoveResource (bookDB, oldIndex); // remove the old resource from the database if (err == errNone) { err = DmAttachResource (bookDB, newH, 'type', id); // attach the new one if (err == errNone) { // arrives here, no error, nothing // but the data is not what it should be } } }
idx++; resIndex = DmFindResourceType (updDB, 'type', idx); // loop to find other resources }
Am I missing something obvious ?
Another question would be, how to do the same "update" but with a database on the card ? Will I have to import it first and then run the same algorithm as above ? Or write my own VFS database update function :)
Kindest Regards, Alex
|
|
 | | From: | Baxter | | Subject: | Re: Update Resources in DB | | Date: | Thu, 25 Nov 2004 10:43:20 -0800 |
|
|
 | This is off the top of my head (I've not actually done this), but I think you'll need to lock down your newH handle and actually write something to a buffer before you attach it.
-- ------------------------------------------------------------------------- Free software - Baxter Codeworks www.baxcode.com -------------------------------------------------------------------------
"Alex" wrote in message news:41a5ab87$0$22503$7b0f0fd3@reader.news.newnet.co.uk... > Hi guyz, > > I am trying to run an update on a resource database. > There don't seem to be such a thing as updating, but more of a delete/add > resource... > > So here is the code : > > resIndex = DmFindResourceType (updDB, 'type', idx); > while (resIndex != 0xFFFF) > { > err = DmResourceInfo (updDB, resIndex, NULL, &id, NULL); // get the id > > newH = DmGetResourceIndex (updDB, resIndex); // get the handle > oldIndex = DmFindResource (bookDB, 'type', id, NULL); // find the old > index > if (oldIndex != 0xFFFF) > { > err = DmRemoveResource (bookDB, oldIndex); // remove the old resource > from the database > if (err == errNone) > { > err = DmAttachResource (bookDB, newH, 'type', id); // attach the new one > if (err == errNone) > { > // arrives here, no error, nothing > // but the data is not what it should be > } > } > } > > idx++; > resIndex = DmFindResourceType (updDB, 'type', idx); // loop to find other > resources > } > > Am I missing something obvious ? > > Another question would be, how to do the same "update" but with a database > on the card ? Will I have to import it first and then run the same algorithm > as above ? Or write my own VFS database update function :) > > Kindest Regards, Alex > >
|
|
|