diff --git a/library/Icinga/Web/FileCache.php b/library/Icinga/Web/FileCache.php index 74f9d08f3..03f0c19dc 100644 --- a/library/Icinga/Web/FileCache.php +++ b/library/Icinga/Web/FileCache.php @@ -154,6 +154,27 @@ class FileCache return $this->basedir . '/' . $file; } + /** + * Prepare a sub directory with the given name and return its path + * + * @param string $name + * + * @return string|false Returns FALSE in case the cache is not enabled or an error occurred + */ + public function directory($name) + { + if (! $this->enabled) { + return false; + } + + $path = $this->filename($name); + if (! is_dir($path) && ! @mkdir($path, octdec('1750'), true)) { + return false; + } + + return $path; + } + /** * Whether the given ETag matches a cached file *