Answer to own question ...
moodlecode/lib/moodlelib.php is one location.
du
clip beginning line 6314
* Adds up all the files in a directory and works out the size.
*
* @param string $rootdir The directory to start from
* @param string $excludefile A file to exclude when summing directory size
* @return int The summed size of all files and subfiles within the root directory
*/
function get_directory_size($rootdir, $excludefile='') {
global $CFG;
// Do it this way if we can, it's much faster.
if (!empty($CFG->pathtodu) && is_executable(trim($CFG->pathtodu))) {
$command = trim($CFG->pathtodu).' -sk '.escapeshellarg($rootdir);
Interesting ... doing a little more digging, there appears to be quite a few
areas in moodle code:
https://searchcode.com/?q=lang%3Aphp%20exec%20source%3ABitbucket%20repo:moodle/moodle