Hello Donald,
According to the FileRead documentation, if the number of blocks read
was less than requested, the EOF indicator is set, so you should be
able to tell if the read finished. After that, perhaps you could use
FileTell to get the size of the file, and thus how many bytes were
read?
I'm
I just check for fileErrEOF and break the loops. If there is another error I
display it to the user (incase it is something in the users power, i.e. no
space, etc.) and then break the loops. Once broken I clean up (I should also
probably delete the vfs file if unsuccessful?? Any suggestions??).
-D
That was a problem I was thinking of. It seems pretty fast (although I am
trying it with a 5MB file on a TX, so it'll be a bit slow). The thing I was
concerned with was it would have 3Kb left to read, so I tell FileRead to
read 1 block of 4096, then FileRead returns 0. So then, how would I figure
o
Adrien Regimbald wrote:
Hello Donald,
Perhaps you're not worried about performance, but wouldn't reading
4096 1 byte blocks be substantially slower than reading 1 4096 byte
block? You just need to do a bit of extra arithmetic to turn the
number of blocks read from FileRead into number of bytes
Hello Donald,
Perhaps you're not worried about performance, but wouldn't reading
4096 1 byte blocks be substantially slower than reading 1 4096 byte
block? You just need to do a bit of extra arithmetic to turn the
number of blocks read from FileRead into number of bytes read.
Adrien.
Tuesday, Ja
Donald C. Kirker wrote:
Problem solved!
great :-)
By the way, should I leave the "if (FileEOF(cache)) break;
FileClearerr(cache);" in there? FileRead seems to return errFileEOF (or
something like that) on its own, I just don't know if this is specific to
any OS release.
I would just ex
Problem solved!
I found out what was wrong. I just assumed (after quickly skimming over the
docs) that FileRead returned the number of bytes read. It in fact returns
the number of blocks read. I had the number of blocks to write set at 1 and
the size of each block set to 4096. FileRead was doi
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) {
> >
> >
BTW: did you seperated your code into the reading part and the writing
part and tested both alone? Just to know, where the problem lies.
The read part should allocate a large array and start reading chunks of
4096 bytes with FileRead(). Check how much bytes you get all together.
The write p
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);
Thanks, I was thinking about that. The only problem is that only 100-400
bytes get written of a 5MB file... I'll have to do a bit mor work, but it
seems hard to get anything constant on my TX.
Thanks again,
Donald
"Thomas Damme" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> You ne
You never check if the end of the filestream maybe reached. From the
docs it seems FileRead does not throw an error when it reached EOF, you
just get 0 read bytes back. And then you still iterate endlessly in you
loop
Thomas
--
For information on using the PalmSource Developer Forums, or
So I have setup the code as I stated earlier, but I am still having issues
copying the data from the File stream to the VFS. It only copies about
100-400 bytes of garbage then freezes. Does anybody have an idea as to what
is happening?
I am investigating this myself too.
Thanks,
Donald
--
For
Mistake, that code won't quite work. This should:
tempData = Malloc(4096);
if (!tempData) {
cacheError(fileErrMemError);
return 2;
}
for (copied = 0; copied < size; copied += numBytesWrittenP) {
MemSet(tempData, 4096, 0);
readBytes = FileRead( cache, tempData, 4096, 1, &fileError);
Ok, thanks. So like this:
Boolean cleanUp = false;
tempData = Malloc(4096);
if (!tempData) {
cacheError(fileErrMemError);
return 2;
}
for (copied = 0; copied < size; copied += numBytesWrittenP) {
MemSet(tempData, 4096, 0);
readBytes = FileRead( cache, tempData, 4096, 1, &fileError);
i
2006/1/12, Henk Jonas <[EMAIL PROTECTED]>:
Do not malloc and free the block inside the loop. Do it outside, breakin the case of error to free the memory again.
Not to mention the waste of speed :)
--
For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://w
Donald C. Kirker wrote:
I forgot to mention, the program hangs in this code:
for (copied = 0; copied < size; copied += numBytesWrittenP) {
tempData = Malloc(4096);
if (!tempData) {
cacheError(fileErrMemError);
return 2;
}
readBytes = FileRead( cache, tempData, 4096, 1, &fileError
17 matches
Mail list logo