Reply to Re: Files getting clobered

Your name:

Reply:


Posted by Henrik Hansen on 05/18/06 11:56

squash@peoriadesignweb.com writes:

> There was some disk space issues with my server. As a result any script
> I had that opened a file for writing would clobber it i.e uncate it to
> zero length . Since there was no space left on device, nothing would be
> written to it.
>
> Are there any workarounds to this? Does opening the r+ or w+ make a
> difference instead of just w ?

w and w+ can be dangerous if you have disk space issues because they
truncate the file on open, without a check if you can write data to
the file again. So i suggest open with r+ and do a is_writable() (i
think it will return false if no disk space is avail) just before you
attempt to write, if it fails, close the file and no data is lost, if
it returns true you can ftruncate() the file to start from 0.
But there can still be issues, like if you dont have enough space to write
the entire content etc...

--
Henrik Hansen

[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

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