Reply to Need help: change a string in a file

Your name:

Reply:


Posted by Saswat Praharaj on 04/06/05 20:07

Hi All,

I need some help in searching string in a file.

My requirement is to search the string,append something to the string .
Write the string back to the file without changing other parts of the file.

e.g
Suppose I have the following string in a file


Set-Cookie: T_COOKIE=127.0.0.1-saswat-9; path=/


The fixed string is "Set-Cookie: T_COOKIE="and rest of the string is variable.
I would like to change the string "127.0.0.1-saswat-9" to say
"127.0.0.1-saswat-9-1234"

My constraint is : I don't want to read the whole file into a buffer
and work on that buffer as the file can be very large , sometimes more
than 10 mb.

My advantage is : I know that I will get the search string in first
200 bytes of the file , so I just need to read 200 bytes,play with
that and write it back (overwriting the first 200 bytes with new 200
some bytes) ..

Would appreciate any help or pointers.

Thanks,
-Saswat

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация