Remove a line from a file?
I want to remove a line from a file which contains a specific string. I did it by doing an empty write_file on that line but that leaves a blank row in a file. How can I delete the line without leaving a blank row?
|
Re: Remove a line from a file?
Read the whole file contents, then write all of the contents into a new file without that 1 line.
Then delete the old file and rename the new file to the old one. |
Re: Remove a line from a file?
Is there another option?
Because the file can have over 2000 lines (steam ids) and it deletes a line 5-6 times per map. The file is accessed over 300 times per map. |
Re: Remove a line from a file?
Desikac
Bufferize the file in an array on plugin_cfg and work with array directly, save it to file on plugin_end. But this will use up as much memory as file size is. You can also try using ftell/fseek (check file.inc). |
Re: Remove a line from a file?
Use write_file and specify the line number, the wanted line won't really be removed but it will be blank.
|
Re: Remove a line from a file?
ConnorMcLeod
I know it's offtopic, but can you tell me, array in pawn use only cellsize*arraysize bytes for memory allocation, or (cellsize+2)*arraysize or (cellsize+4)*arraysize ? |
Re: Remove a line from a file?
I have no idea of what you are talking about ;)
|
Re: Remove a line from a file?
ConnorMcLeod
I mean, is pawn using just a dinamic array, one-way vector (with data* next) or two-way vector (with data* next, prev) ? By saying "one-way vector" I mean something like this (sorry for my poor knowledge or english computer terms): PHP Code:
|
Re: Remove a line from a file?
Quote:
|
Re: Remove a line from a file?
Quote:
|
| All times are GMT -4. The time now is 04:25. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.