file_space_used

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 file_space_used($uid = NULL)
drupal7 file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT)

Determine total disk space used by a single user or the whole filesystem.

Übergabeparameter

$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.

Rückgabewert

An integer containing the number of bytes used.

Verwandte Themen

▾ 5 functions call file_space_used()

FileSpaceUsedTest::testStatus in modules/simpletest/tests/file.test
Test the status fields
FileSpaceUsedTest::testUser in modules/simpletest/tests/file.test
Test different users with the default status.
FileSpaceUsedTest::testUserAndStatus in modules/simpletest/tests/file.test
Test both the user and status.
file_validate_size in includes/file.inc
Check that the file's size is below certain limits.
upload_space_used in modules/upload/upload.module
Determine how much disk space is occupied by a user's uploaded files.

Code

includes/file.inc, line 851

<?php
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();
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen