By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,521 Members | 1,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,521 IT Pros & Developers. It's quick & easy.

fwrite when out of storage space

P: n/a
I have a problem that has long plagued me:
What is the best way to check if I'm out of space?
I have a file editor application (could apply to anything though).
If the server (Apache on SunOS) is out of diskspace
$fp = fopen($file,'w');
fwrite($fp,$string,strlen($string));
fclose($fp);
creates a nice 0-byte file.. no error or anything.

Do I need to write to a test file and check it's filesize first??
There's gotta be a better way.

This is a server where the log files get out of control and that's out
of my jurisdiction.
Jul 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,

BKDotCom wrote:
I have a problem that has long plagued me:
What is the best way to check if I'm out of space?
I have a file editor application (could apply to anything though).
If the server (Apache on SunOS) is out of diskspace
$fp = fopen($file,'w');
fwrite($fp,$string,strlen($string));
fclose($fp);
creates a nice 0-byte file.. no error or anything.

Do I need to write to a test file and check it's filesize first??
There's gotta be a better way.

This is a server where the log files get out of control and that's out
of my jurisdiction.


http://uk2.php.net/manual/en/functio...free-space.php

Luke

Jul 16 '05 #2

P: n/a
BKDotCom wrote:

I have a problem that has long plagued me:
What is the best way to check if I'm out of space?
I have a file editor application (could apply to anything though).
If the server (Apache on SunOS) is out of diskspace
$fp = fopen($file,'w');
fwrite($fp,$string,strlen($string));
fclose($fp);
creates a nice 0-byte file.. no error or anything.

Have you tried checking the return from fclose() in this situation? In
C, there usually will be an error return because the file buffers can't
be written. Similarly an explicit fflush() normally indicates error when
the data cannot be physically written to the device.


Brian Rodenborn
Jul 16 '05 #3

P: n/a
Thanks!
However I have brought shame to my family...
not sure how I missed that... old problem though.. pre ver 4.1

Luke Ross <lu******@sys3175.co.uk> wrote in message news:<vk************@corp.supernews.com>...
Hi,

BKDotCom wrote:
I have a problem that has long plagued me:
What is the best way to check if I'm out of space?
I have a file editor application (could apply to anything though).
If the server (Apache on SunOS) is out of diskspace
$fp = fopen($file,'w');
fwrite($fp,$string,strlen($string));
fclose($fp);
creates a nice 0-byte file.. no error or anything.

Do I need to write to a test file and check it's filesize first??
There's gotta be a better way.

This is a server where the log files get out of control and that's out
of my jurisdiction.


http://uk2.php.net/manual/en/functio...free-space.php

Luke

Jul 16 '05 #4

P: n/a
I'm pretty sure the return value was always non-false.
Not like a false value does any good after it's wiped the file.

Default User <fi********@company.com> wrote in message

Have you tried checking the return from fclose() in this situation? In
C, there usually will be an error return because the file buffers can't
be written. Similarly an explicit fflush() normally indicates error when
the data cannot be physically written to the device.

Brian Rodenborn

Jul 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.