[physfs] open for append & seek & write?

Ryan C. Gordon icculus at icculus.org
Thu Apr 3 01:10:15 EDT 2008

Vaclav Vanc wrote:
> Platform is Linux i386
> Look at this part of code:

Hmm...that's a bug.

Fixed in svn revision #940 for the 1.1 branch and #941 for the 1.0 branch.

This program now works as you'd expect with that fix (although note that 
if file.txt is empty, it'll write two '\0' chars to the start, since 
we're seeking past the end of file. I don't think PhysicsFS makes any 
guarantees on that behaviour at the moment).

#include <stdio.h>
#include "physfs.h"

int main(int argc, char **argv)
     char string[]="TEST";
     PHYSFS_file *file = PHYSFS_openAppend("file.txt");
     printf("tell == %d\n",(int) PHYSFS_tell(file));
     printf("seek 2 == %d\n", (int) PHYSFS_seek(file, 2));
     printf("tell == %d\n",(int) PHYSFS_tell(file));
     printf("write 4 == %d\n", (int) PHYSFS_write(file,  string, 1, 4));
     printf("tell == %d\n", (int) PHYSFS_tell(file));
     return 0;


More information about the physfs mailing list