You are here

function advagg_delete_files_if_empty in Advanced CSS/JS Aggregation 7.2

Given an array of files remove that file if it is empty.

Parameters

array $files: Array of files returned by file_scan_directory.

Return value

array Array of files that got removed.

1 call to advagg_delete_files_if_empty()
advagg_delete_empty_aggregates in ./advagg.cache.inc
Scan CSS/JS advagg dir and remove that file if it is empty.

File

./advagg.cache.inc, line 318
Advanced CSS/JS aggregation module.

Code

function advagg_delete_files_if_empty(array $files) {

  // Array used to record what files were deleted.
  $kill_list = array();
  foreach ($files as $uri => $file) {

    // Ignore temp files.  There's a separate process for cleaning those up.
    if (strpos($uri, '/advagg_file_') !== FALSE) {
      continue;
    }
    $size = filesize($uri);
    if ($size === 0) {
      $kill_list[] = advagg_delete_file_by_uri($uri);
      continue;
    }
  }

  // Let other modules know about the removed files.
  // Call hook_advagg_removed_aggregates().
  module_invoke_all('advagg_removed_aggregates', $kill_list);
  return $kill_list;
}