/** * Check if the filter select the specified file. * * @param Charcoal_File $file Target fileto be tested. */ public function accept(Charcoal_File $file) { if ($this->extension) { $ext = $file->getExtension(); if ($ext != $this->extension) { return FALSE; } } $suffix = $this->extension ? s('.' . $this->extension) : NULL; $name = $suffix ? $file->getName($suffix) : $file->getName(); if (preg_match($this->pattern, $name)) { return TRUE; } return FALSE; }
/** * クリーンアップ */ public function cleanUp($action, $context) { $action = us($action); switch ($action) { case "get_empty_data": case "get_integer_data": case "get_string_data": case "get_array_data": case "get_boolean_data": case "get_float_data": case "get_object_data": case "set_duration": case "delete": case "delete_wildcard": case "delete_regex": case "touch": case "touch_wildcard": case "touch_regex": $cache_files = glob($this->cache_root . '/*'); if ($cache_files && is_array($cache_files)) { foreach ($cache_files as $cache) { $file = new Charcoal_File(s($cache)); $name = $file->getName(); $ext = $file->getExtension(); if ($file->exists() && $file->isFile() && in_array($ext, array("meta", "data"))) { $file->delete(); echo "removed cache file: [{$cache}]" . eol(); } } } break; default: break; } }