Raised This Month: $ Target: $400
 0% 

Writing first line of a file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 01-17-2013 , 23:56   Writing first line of a file
Reply With Quote #1

Hello,

Is there a way to write the first line of a file and keep the other lines already written ?

For example:

-> Line 5
-> Line 4
-> Line 3
-> Line 2
-> Line 1

We can call it a reverse from the log_to_file function. The only difference is that the text written inside of the file will be on a reversed order.

Also, if possible, to keep only a specific number of lines, for example maximum 100.

I found a sample from PHP but I think that copying the entire file content into memory, just to add one more line then rewrite the new content is bad for memory.

I am wondering if it's possible to write something on the first line of a file without copying the entire file content.

Thank you.
DjOptimuS is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode