17.11.2011, 03:13
If you use io_read and the file doesn't exist, the server will crash.
Add a check to confirm the file you're trying to open with fopen()'s io_read parameters actually exists.
Not sure if this crash is exclusive to Linux.
Add a check to confirm the file you're trying to open with fopen()'s io_read parameters actually exists.
Not sure if this crash is exclusive to Linux.
pawn Code:
stock fdeleteline(filename[], removed[])
{
new string[64], str[32], File:handle, File:ftmp;
if(fexist(filename)) handle = fopen(filename,io_read); else return 0;
format(str,sizeof(str),"%s.part",filename);
if(fexist(str)) ftmp = fopen(str,io_write); else return 0;
while(fread(handle,string))
if(strfind(string,removed) == -1)
fwrite(ftmp,string);
fclose(handle);
fclose(ftmp);
handle = fopen(filename,io_write);
if(fexist(str)) ftmp = fopen(str,io_read); else return 0;
while(fread(ftmp,string))
fwrite(handle,string);
fclose(handle);
fclose(ftmp);
return fremove(str);
}