20.12.2018, 18:35
Testa isso:
PHP код:
LineSub(const filename[], const coment[], lineid)
{
if (!fexist(filename))
{
return 0;
}
new
File: temp=fopen("temp.tmp", io_write),
File: pfile=fopen(filename, io_read),
line, tmp[128]
;
if (!pfile)
{
return 0;
}
while(fread(pfile, tmp))
{
line ++;
if (line != lineid)
{
fwrite(temp, tmp);
}
else
{
fwrite(temp, coment);
fwrite(temp, "\r\n");
}
}
fclose(temp);
fclose(pfile);
if ((pfile = fopen(filename, io_write)))
{
if ((temp = fopen("temp.tmp", io_read)))
{
new nchar;
while((nchar = fgetchar(temp, 0, true)) != EOF)
{
fputchar(pfile, nchar);
}
}
}
fclose(temp);
fclose(pfile);
fremove("temp.tmp");
return 1;
}