You are here

function dirsize in TinyBrowser 7

3 calls to dirsize()
qqFileUploader::handleUpload in tinybrowser/fileuploader.php
Returns 'Success' or 'Error: (error message)' string
upload.php in tinybrowser/upload.php
upload_file.php in tinybrowser/upload_file.php

File

tinybrowser/fns_tinybrowser.php, line 3

Code

function dirsize($dir) {
  $s = stat($dir);
  $space = $s['blocks'] * 512;
  $size = 0;
  if (is_dir($dir)) {
    $dh = opendir($dir);
    while (($file = readdir($dh)) !== FALSE) {
      if ($file != "." && $file != ".." && !is_link($dir . '/' . $file)) {
        $result = dirsize($dir . "/" . $file);
        $space += $result['space'];
        $size += $result['size'];
      }
    }
    closedir($dh);
  }
  else {
    $size = filesize($dir);
  }
  $total['size'] = $size;
  $total['space'] = $space;
  return $total;
}