TrieDeleteKey() will remove the item from the trie, not the actual file. You must recreate the entire file in order to remove a line.
Not sure what's exactly wrong in your code, but I can offer you a "cleaner" way of doing it.
Instead of making a temporary file, renaming and deleting it, store all lines of your file in a dynamic array when reading it, EXCEPT the lines that are already expired.
Then, after closing the file, open it again in write mode, loop through the array and write all lines. Pseudo-code:
Code:
new szFile[256]
get_configsdir(szFile, charsmax(szFile))
add(szFile, charsmax(szFile), "/YourFile.ini") // cleaner way with only 1 variable
new iFilePointer = fopen(szFile, "r") // open the file in "read" mode
if(iFilePointer)
{
const MAX_LINE_LENGTH = 256
new Array:aArray = ArrayCreate(MAX_LINE_LENGTH)
new iLinesInFile // this will count the number of non-expired lines in the file when reading
new bool:bShouldRewrite // this will determine whether the file should be rewritten
new szData[MAX_LINE_LENGTH]
while(!feof(iFilePointer))
{
fgets(iFilePointer, szData, charsmax(szData))
trim(szData)
if(/* line is expired */)
{
// at least one line has expired - entire file needs to be rewritten in order to remove the line(s)
bShouldRewrite = true
}
else
{
// store the non-expired line in the array
iLinesInFile++
ArrayPushString(aArray, szData)
}
}
fclose(iFilePointer)
if(bShouldRewrite)
{
iFilePointer = fopen(szFile, "w") // open the file in "write" mode
for(new i; i < iLinesInFile; i++) // loop through the array and write each line in the file
{
fprintf(iFilePointer, "%a^n", ArrayGetStringHandle(aArray, i)) // %a is used to get a string directly from a dynamic array
}
fclose(iFilePointer)
}
ArrayDestroy(aArray)
}
__________________