function advagg_file_exists in Advanced CSS/JS Aggregation 7
Same name and namespace in other branches
- 6 advagg.module \advagg_file_exists()
 
Use a cache table to see if a file exists.
Parameters
$filename: name of file
Return value
TRUE or FALSE
2 calls to advagg_file_exists()
- advagg_build_js_bundle in ./
advagg.module  - Given a list of files, grab their contents and glue it into one big string.
 - advagg_process_css in includes/
css.inc  - Returns a themed representation of all stylesheets that should be attached to the page.
 
File
- ./
advagg.module, line 2423  - Advanced CSS/JS aggregation module
 
Code
function advagg_file_exists($filename) {
  static $files = array();
  if (empty($files)) {
    $data = cache_get('advagg_file_checksum', 'cache');
    if (empty($data->data)) {
      $result = db_query("SELECT filename, checksum FROM {advagg_files}");
      while ($row = $result
        ->fetchAssoc()) {
        $files[$row['filename']] = $row['checksum'];
      }
      cache_set('advagg_file_checksum', $files, 'cache', CACHE_TEMPORARY);
    }
    else {
      $files = $data->data;
    }
  }
  if (!empty($files[$filename]) && $files[$filename] != -1) {
    return TRUE;
  }
  else {
    advagg_clearstatcache(TRUE, $filename);
    return file_exists($filename);
  }
}