Hi,
I would need to remove few lines from end of file and was wondering what would be the best way to do it. Basically the file may contain this at the end, for example:
...
</entry>
</events>
So I would need to remove </entry> and </events> before proceeding and also in the end of file or between those lines there may be line change.
I'm planning to use truncate() -function for that to remove the last line (first getting the address of last line), and then to check if line is beginning with line change or the line matches </entry> or </events>.
Does this sound a good way to remove these lines from file or is there more convenient way?
One would be of course to read the file into memory, remove lines and then write it back, but that may not be feasible, since it eats memory.
I would need to remove few lines from end of file and was wondering what would be the best way to do it. Basically the file may contain this at the end, for example:
...
</entry>
</events>
So I would need to remove </entry> and </events> before proceeding and also in the end of file or between those lines there may be line change.
I'm planning to use truncate() -function for that to remove the last line (first getting the address of last line), and then to check if line is beginning with line change or the line matches </entry> or </events>.
Does this sound a good way to remove these lines from file or is there more convenient way?
One would be of course to read the file into memory, remove lines and then write it back, but that may not be feasible, since it eats memory.