gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > fread bug ? (bad return value)

#130579 - thoduv - Tue Jun 05, 2007 3:20 pm

Hi!

Fread is assumed to return the amount of data that was actually read, but with devkitpro r20 and latest libfat, it only returns 0 or 1 (even when more data was actually read).
It's possibly a bug from Devkitpro, so I wanted to know if someone constated it before, if I am wrong, or if this is known bug.

Thanks !
Thoduv

#130594 - simonjhall - Tue Jun 05, 2007 6:34 pm

It's supposed to return the amount of elements read.
So say you want to read 1234 bytes, you could do

fread(buffer, 1, 1234, fp)
or
fread(buffer, 1234, 1, fp)

assuming everything's peachy, 1) will return 1234 and 2) will return 1, yet both will read 1234 bytes into buffer.
Or have I got the wrong end of the stick here? :-)
_________________
Big thanks to everyone who donated for Quake2

#130604 - thoduv - Tue Jun 05, 2007 7:57 pm

Oh, I didn't know !
Sorry for the bug suspicion and thank you for the info ! :)