This looks similer to my problem with File Stream.
 I am trying to modify a File  with FileWrite at a perticuler file
position(middle of  the file). After the write, the file gets truncated
and I am losing the rest of the file content.

The following is what I do...

static int WriteChars(CharPtr filename, CharPtr text, long seekPos)
{

    FileHand theStream = NULL;
    int numObjects=0;
    theStream = FileOpen(0, filename, sysFileTFileStream, creatorId,
fileModeUpdate, &err);
     FileSeek(theStream, seekPos, fileOriginBeginning);
    numObjects = FileWrite(theStream, text, (long) sizeof(char),
(long)(StrLen(text)-1), &err);
    FileFlush(theStream);
    FileClose(theStream);
    return numObjects;
}

I will highly appreciate your help.

Thank you,
Chida

Steve Mann wrote:

> >should I delete a record
> >and then add the new record fresh for an edit or should I use DmWrite or
> >another function that I have missed?
>
> In my experience, it kind of depends on the situation. There's no one
>
> right answer.
>
> If you have to do a  _lot_ of DmWrites, for instance, to update
> several different discrete byte ranges, then maybe deleting and
> creating a new record makes sense. It's simpler, easier, and more
> straightforward code. If you are buffering all the new data in a
> struct and can just blast it into the existing record, and it'a all
> the same size, DmWrite works fine.
>
> There are no other wildly relevant functions, except there is one Fld
> function that lets you update a record in place, from a field's text,
> as long as you are only doing that with one field.  The technique is
> described in the Rhodes/McKeehan book.
>
> Regards,
> Steve Mann
>
> --
> -------------------------------------------
> Creative Digital Publishing Inc.
> 1315 Palm Street, San Luis Obispo, CA 93401-3117
> -------------------------------------------
> 805.784.9461              805.784.9462 (fax)
> [EMAIL PROTECTED]       http://www.cdpubs.com


-- 
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