P
Piotr
What is the simple function checking free disk space ?
thank you
thank you
Piotr said:What is the simple function checking free disk space ?
Piotr said:What is the simple function checking free disk space ?
thank you
There isn't one in standard C.
In said:What is the simple function checking free disk space ?
Christopher Benson-Manica said:Piotr <[email protected]> spoke thus:
There isn't one in standard C. If you're using Unix, the du and/or quota
commands may be useful to you.
Alex said:Off-topic: du? I hope you mean 'df'.
open a file,
write to the file until you get an error, counting bytes
close and reopen the file to free the space
close the file
Now the filesystem should have atleast as much free space as the bytes
you counted.
But he'd probably be better of using a platform specific way![]()
What you suggested IS a platform specific way. If you try it on a file
system with file versioning when you reopen the file it might just
create a new version of the file leaving the old on on the disk.
Ouch
If you
use a temporary file instead, it might be held in memory and therefor
report free space even if the disk is full.
open a file,
write to the file until you get an error, counting bytes
close and reopen the file to free the space
close the file
Now the filesystem should have atleast as much free space as the bytes you
counted.
But he'd probably be better of using a platform specific way![]()
Mark Gordon said:What you suggested IS a platform specific way. If you try it on a file
system with file versioning when you reopen the file it might just
create a new version of the file leaving the old on on the disk. If you
use a temporary file instead, it might be held in memory and therefor
report free space even if the disk is full.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.