|
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
Navigation:
[Reply to this message]
|