function fs_unlink($path, $match, $recursive = false) { $dirs = glob($path . "*"); $files = glob($path . $match); foreach ($files as $file) { if (is_file($file)) { unlink($file); } } foreach ($dirs as $dir) { if ($recursive && is_dir($dir)) { $dir = basename($dir) . "/"; fs_unlink($path . $dir, $match); } } }
function fs_remove($path) { if (fs_is_dir($path)) { $a = fs_dir($path); $rc = true; for ($i = 0; $i < count($a); $i++) { $rc = $rc && fs_remove($path . "/" . $a[$i]); } return $rc && fs_remove_dir($path); } else { return fs_unlink($path); } }
function fs_clean_ip2c_temp() { $dir = $GLOBALS['FS_TEMP_DIR']; fs_unlink($dir, "fs_ip2c_*"); unlink("{$dir}/db.version"); unlink("{$dir}/ip-to-country.bin"); }