You are here

function fancy_file_delete_unmanaged_get_files in Fancy File Delete 7

Answer an array of unmanaged files contained in the directories provided.

Parameters

array $paths Directory paths e.g. array("public://", "public://media"):

Return value

array of file objects.

1 call to fancy_file_delete_unmanaged_get_files()
fancy_file_delete_unmanaged_update_view in ./fancy_file_delete.module
Updates the view and populates the unmanaged files table.

File

./fancy_file_delete.module, line 293

Code

function fancy_file_delete_unmanaged_get_files(array $paths) {

  // Get all files from default standard file dir.
  $file_check = array();
  foreach ($paths as $path) {
    $file_check = array_merge($file_check, fancy_file_delete_unmanaged_get_file_uris($path));
  }
  $db_check = array();

  // All the files in the file_managed table
  // I changed this to use db_query for performance.
  // see issue: https://www.drupal.org/node/2637028
  $query = db_query('SELECT uri FROM {file_managed}');

  // Set this to a numeric keyed array so we can check this easier.
  foreach ($query
    ->fetchAll() as $result) {
    $db_check[] = $result->uri;
  }

  // Get the files not in the file_managed table.
  return array_diff($file_check, $db_check);
}