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>';
?>
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.