open for append & seek & write?

Vaclav Vanc vanc.vaclav at gmail.com
Sun Mar 30 09:25:03 EDT 2008


Hi  is it possible, to open existing file, seek in the middle and
write something?
Here is my code...

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

int main(int argc, char *argv[])
{
char string[]="TEST";

PHYSFS_init(argv[0]);
PHYSFS_permitSymbolicLinks( 1 );
PHYSFS_setWriteDir("./");
PHYSFS_addToSearchPath( "./", 0 );

PHYSFS_file *file = PHYSFS_openAppend("file.txt");

PHYSFS_seek(file, 2);
PHYSFS_write(file,  string, 1, 4);

PHYSFS_close(file);
return EXIT_SUCCESS;
}

It should open existing file,  seek to 2th byte from start and write 4
bytes. Unfortunately these 4 bytes are written to the end of the file.
What I am doing wrong?

Thanks.



More information about the physfs mailing list