Hi,
I have a requirement to edit a remote text file on-the-fly, the content of which currently stands at ~1Mb.
I have tried a couple of approaches and both seem to be clunky or hog memory which I can't rely on.
Thinking out logically what I'm trying to achieve is:
- FTP to a remote server.
- Download a copy of the file for backup purposes and store it somewhere locally.
- Open the remote file and add the necessary lines required.
- Remove lines from the remote file as per an array of un-required data generated from the local server.
Is this possible?
I've managed to code steps 1 and 2 but I'm having difficult with 3 and 4. The way I'm doing it now is to use fgets and return the whole string. Really, I don't want to do this as it involves manipulating and re-generating the whole string (and it's large) and then re-inserting it in between two markers in the remote file.
Is there no way of manipulating the lines of text in the file on-the-fly?