You are here

function fac_delete_json_files in Fast Autocomplete 7

Delete Fast Autocomplete json files.

Parameters

string $expire_time: An optional expire time to only delete files older than the given date.

4 calls to fac_delete_json_files()
fac_cron in ./fac.module
Implements hook_cron().
fac_delete_form_submit in inc/fac.admin.inc
Submit handler for the fac_delete_form.
fac_uninstall in ./fac.install
Implements hook_uninstall().
fac_update_7101 in ./fac.install
Remove all old fac JSON files to support the new folder structure with hmac.

File

./fac.module, line 356
This file contains the main functions of the Fast Autocomplete module.

Code

function fac_delete_json_files($expire_time = '') {
  if (empty($expire_time)) {

    // No date and time given so just delete the entire directory.
    file_unmanaged_delete_recursive(FAC_JSON_FILES_DIRECTORY);
  }
  else {

    // Get all Fast Autocomplete json files.
    $json_files = file_scan_directory(FAC_JSON_FILES_DIRECTORY, '/.*\\.json$/');

    // Loop through all the files and delete those that have expired.
    foreach ($json_files as $json_file) {
      if (filectime($json_file->uri) < $expire_time) {
        file_unmanaged_delete($json_file->uri);
      }
    }
  }
}