First replace your PF_fopen with this version:
Code: Select all
void PF_fopen (void)
{
char *p = G_STRING(OFS_PARM0);
int fmode = G_FLOAT (OFS_PARM1);
int h = 0;
switch (fmode)
{
case 0: // read
Sys_FileOpenRead (va("%s/%s",com_gamedir, p), &h);
break;
case 1: // append -- sane version
h = Sys_FileOpenAppend (va("%s/%s", com_gamedir, p));
break;
default: // write
h = Sys_FileOpenWrite (va("%s/%s", com_gamedir, p));
break;
}
// always common now
G_FLOAT (OFS_RETURN) = (float) h;
}
Code: Select all
int Sys_FileOpenAppend (char *path)
{
FILE *f;
int i;
i = findhandle ();
f = fopen (path, "ab");
// change this Sys_Error to something that works in your code
if (!f)
Sys_Error ("Error opening %s: %s", path, strerror (errno));
sys_handles[i] = f;
return i;
}
Code: Select all
int Sys_FileOpenAppend (char *path);