VOGONS


Question about r3980

Topic actions

First post, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

I agree that fwrite should have sector_size as the third rather than the second parameter so as not to always return 1, but I don't understand why it makes a difference whether the last action was a read or write for deciding whether fseek is needed or not.

Reply 1 of 1, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

from https://www.daemon-systems.org/man/fwrite.3.html

     Mixing fread() and fwrite() calls without setting the file position
explicitly using fsetpos(3) between read and write or write and read
operations will lead to unexpected results because of buffering the file
pointer not being set to the expected position after each operation
completes. This behavior is allowed by ANSI C for efficiency and it will
not be changed.

Water flows down the stream
How to ask questions the smart way!