Reputation: 5651
I'm not clear on what disk_free_space
and disk_total_space
are supposed to do.
The documentation says "Returns available space on filesystem or disk partition" and "Returns the total size of a filesystem or disk partition", respectively. Meanwhile, the argument is described, in each case, as "A directory of the filesystem or disk partition."
So am I able to get the available disk space only for a partition or also for a specific folder?
In other words, is it normal that both parts of this script return the same values?
<?php
$path = '/home/bilingueanglais'; // an estimated 14 GB according to Webmin
$free = floor( disk_free_space( $path ) / ( 1024 * 1024 ) );
$total = floor( disk_total_space( $path ) / (1024 * 1024 ) );
echo 'Diskspace for path `' . $path . '`:<br>';
echo $free . 'MB out of ' . $total . ' MB<br><br><br>';
$path = '/home/bilingueanglais/public_html/assets/theme'; // just 225 KB in reality
$free = floor( disk_free_space( $path ) / ( 1024 * 1024 ) );
$total = floor( disk_total_space( $path ) / (1024 * 1024 ) );
echo 'Diskspace for path `' . $path . '`:<br>';
echo $free . 'MB out of ' . $total . ' MB<br><br><br>';
?>
Upvotes: 0
Views: 4685
Reputation: 32272
It's a *nix convention. Let's say you've got a filesystem mounted on /var/www
:
disk_free_space('/var/www');
will return the same result as disk_free_space('/var/www/foobar.com');
because they are the same filesystem and that's what the function reporting.
What you're running is likely reporting the disk usage of the entire server, not just your user.
Upvotes: 1
Reputation: 18907
It's returning the same values because those functions specifically look at the volume free/total capacity respectively.
Think of it like the output of df
on Linux/OS X/etc - it shows disk/volume sizes not directory sizes.
Upvotes: 0