public static function checkCacheDir()
{
$dir = self::$cache_dir;
if (!is_dir($dir)) {
$old = umask(0);
if (!mkdir($dir, 0777, TRUE)) {
throw new Haanga_Exception("{$dir} is not a valid directory");
}
umask($old);
}
if (!is_writable($dir)) {
throw new Haanga_Exception("{$dir} can't be written");
}
}