on 2/12/01 5:32 PM, Danny Epstein at [EMAIL PROTECTED] wrote:

> "Chad Harrison" <[EMAIL PROTECTED]> wrote in message
> news:39360@palm-dev-forum...
>> any pointers on creating this "self-extracting" archive? I still need to
>> support < 3.5.
> 
> It's an idea that's been floating around for a while on this forum - check
> the archives. I was going to say that the implementation was left as an
> exercise for the reader. :) Ideally, the self-extracting archive should
> gradually delete itself as it expands. You shouldn't need twice as much free
> memory as the data actually consumes. This is one of the tricky parts.
> Another trick is deleting the final "stub" when you're all done - how do you
> delete yourself? Fun, fun!
> 

Here's what I've done for self-extracting:
    Let's say you've got a large pdb file (in my case a 4 Mb with 15,000
records that took forever to sync), call it foo.pdb.
    Create FooCompressed.pdb that contains the 4 Mb split into 20K chunks
(add compression to taste).
    A helper app reads the 20K chunks. Unfortunately, you can't use
DmCreateDatabaseFromImage (because it takes a pointer to the entire pdb).
What's odd is that you also can't use ExgDBRead.  The problem is the
implementation of ExgDBRead. It reads the database header and allocates a
handle of the final size for each record.  What that means is that by the
time you've read 20K or 30K into FooCompressed.pdb, you've got to have on
the device both the contents of all the records (the rest of
FooCompressed.pdb), plus the allocated records.  Thus, you need twice the
space.
The solution is to write your own version of ExgDBRead that allocates each
final record on a pay-as-you-go basis (e.g., as you're about to read the
contents of record n, allocate the space for it).
Then, as you're finished with a particular 20K chunk, delete it.
If you've got a problem while you're doing the decompression, though, you
can't start over, because you've deleted some of the important data.

I never did get the self-deletion working.


Neil


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to