Determines total disk space used by a single user or the whole filesystem.
int $uid: Optional. A user id, specifying NULL returns the total space used by all non-temporary files.
$status: Optional. The file status to consider. The default is to only consider files in status FILE_STATUS_PERMANENT.
int An integer containing the number of bytes used.
public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT) {
$query = db_select($this->entityInfo['base_table'], 'f')
->condition('f.status', $status);
$query
->addExpression('SUM(f.filesize)', 'filesize');
if (isset($uid)) {
$query
->condition('f.uid', $uid);
}
return $query
->execute()
->fetchField();
}