Quote:
Originally Posted by HamletEagle
That's basic string manipulation, nothing to do with files.
1.Shift all cell's content one position to the right and then overwrite the first one.
2.Use formatex in another string, like formatex(..., ..., ";%s", Line).
3.Use strcat.
|
I totally forgot about formatex
Is NewLine[] purposely not used or you just forgot?
PHP Code:
stock RemoveLine(const FileName[], const OldLine[], const NewLine[])
{
new const TempFileName[] = "tempfile.ini"
new ConfigDirPath[128]; get_configsdir(ConfigDirPath, charsmax(ConfigDirPath))
new FullPath[256]; formatex(FullPath, charsmax(FullPath), "%s/%s", ConfigDirPath, FileName)
new FilePointer = fopen(FullPath, "rt")
if(FilePointer)
{
new TempFilePath[256]; formatex(TempFilePath, charsmax(TempFilePath), "%s/%s", ConfigDirPath, TempFileName)
new InputFilePointer = fopen(TempFilePath, "wt")
if(InputFilePointer)
{
new FileData[128]
while(!feof(FilePointer))
{
fgets(FilePointer, FileData, charsmax(FileData))
trim(FileData)
if(equal(FileData, OldLine))
{
continue
}
fprintf(InputFilePointer, "%s^n", FileData)
}
fclose(InputFilePointer)
fclose(FilePointer)
delete_file(FullPath)
rename_file(TempFilePath, FullPath, 1)
return 1
}
}
return 0
}
__________________