file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT)
drupal/includes/file.inc, line 768
Determine total disk space used by a single user or the whole filesystem.
$uid Optional. A user id, specifying NULL returns the total space used by all non-temporary files.
$status Optional. File Status to return. Combine with a bitwise OR(|) to return multiple statuses. The default status is FILE_STATUS_PERMANENT.
An integer containing the number of bytes used.
| Name | Description |
|---|---|
| File interface | Common file handling functions. |
function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) {
$query = db_select('files', 'f');
// Use separate placeholders for the status to avoid a bug in some versions
// of PHP. @see http://drupal.org/node/352956
$query->where('f.status & :status1 = :status2', array(':status1' => $status, ':status2' => $status));
$query->addExpression('SUM(f.filesize)', 'filesize');
if (!is_null($uid)) {
$query->condition('f.uid', $uid);
}
return $query->execute()->fetchField();
}