All pastes #814845 Raw Edit

fdeleteline

public cpp v1 · immutable
·published 2007-12-13 16:14 UTC
rendered paste body
stock fdeleteline(filename[], line[]){		if (fexist(filename))	{		new			temp[256],			File:fHnd1 = fopen(filename, io_read),			len = strlen(line);		if (fHnd1)		{			new				File:fHnd2 = ftemp();			if (fHnd2)			{				while (fread(fHnd1, temp))				{					if (strcmp(temp, line, .length = len))					{						fwrite(fHnd2, line);					}				}				fclose(fHnd1);				fremove(filename);				fHnd1 = fopen(filename, io_write);				if (fHnd1)				{					while (fread(fHnd2, line))					{						fwrite(fHnd1, line);					}					fclose(fHnd1);					fclose(fHnd2);					return 1;				}				fclose(fHnd2);			}			fclose(fHnd1);		}	}	return 0;}