Where might one find the code that uses /usr/bin/du

Where might one find the code that uses /usr/bin/du

by Ken Task -
Number of replies: 1
Picture of Particularly helpful Moodlers

or other operating system (normally cli) scripts.

http://php.net/manual/en/function.shell-exec.php

but I'd like to see how Moodle code has used such things.

Have an idea for a 'proper' local plugin for 'snapshot' (word seen in the warning when one is installing a plugin/addon).

Thanks, in advance,

Ken

Average of ratings: -
In reply to Ken Task

Re: Where might one find the code that uses /usr/bin/du

by Ken Task -
Picture of Particularly helpful Moodlers

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