/** * Gets the cache prefix, dependent of the used browscap dataset type. * * @return string */ protected static function getCachePrefix() { switch (Browscap::getDatasetType()) { case Browscap::DATASET_TYPE_SMALL: return 'smallbrowscap'; case Browscap::DATASET_TYPE_LARGE: return 'largebrowscap'; default: return 'browscap'; } }
/** * Gets the main/version cache directory * * @param boolean $with_version * @param bool $create_dir * @return string */ public static function getCacheDirectory($with_version = false, $create_dir = false) { // get sub directory name, depending on the data set type // (one sub directory for each data set type and version) switch (Browscap::getDatasetType()) { case Browscap::DATASET_TYPE_SMALL: $subDirName = 'smallbrowscap'; break; case Browscap::DATASET_TYPE_LARGE: $subDirName = 'largebrowscap'; break; default: $subDirName = 'browscap'; } if (static::$cache_dir === null) { static::setCacheDirectory(sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'browscap'); } $path = static::$cache_dir; if ($with_version === true) { $path .= DIRECTORY_SEPARATOR . $subDirName; $path .= '_v' . Browscap::getParser()->getVersion(); $path .= '_' . Browscap::VERSION; } if ($create_dir === true && !file_exists($path)) { mkdir($path, 0777, true); } return $path; }