FileCache: Add method to prepare sub directories

refs #3814
This commit is contained in:
Johannes Meyer 2019-06-25 16:15:33 +02:00
parent bd2060739e
commit 74642d1cf7
1 changed files with 21 additions and 0 deletions

View File

@ -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
*