Thanks, I will try this and also the other suggestion by Henk. I intend on debugging it now that I have the time.
-Donald "Logan Shaw" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Donald C. Kirker wrote: > > for (copied = 0; copied < size; copied += numBytesWrittenP) { > > > > MemSet(tempData, 4096, 0); > > There is no need at all to do a MemSet(). The FileRead() is > going to write over the stuff in the buffer anyway. > > > readBytes = FileRead( cache, tempData, 4096, 1, &fileError); > > if (fileError != errNone) { > > cacheError(fileError); > > loopError = true; > > break; > > } > > This looks OK, although I'd put 4096 as a constant instead of > putting it as a literal value in a zillion places. > > > err = VFSFileWrite(fileRefP, readBytes, tempData, &numBytesWrittenP); > > if (err != errNone) { > > VfsError(err); > > loopError = true; > > break; > > } > > } > > This code isn't correct. VFSFileWrite() does not guarantee that it > will write everything in your buffer. Your buffer could have 512 > bytes in it and VFSFileWrite() might write only 17 of them the first > time you call it. > > So, you need a loop around VFSFileWrite(); something like this: > > UInt32 bufferoffset = 0; > do > { > err = VFSFileWrite (fileRefP, > readBytes - bufferoffset, tempData + bufferoffset, > & numBytesWrittenP); > // error handling goes here > > bufferoffset += numBytesWrittenP; > } while (bufferoffset < readBytes); > > What that does is starts at the beginning of your buffer, then > writes as much of it as possible, advancing the offset by however > much was *actually* written, then keeps going as long as what's > in the buffer hasn't all been written yet. > > - Logan > -- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
