Skip to content

Commit

Permalink
FileCache: Add method to prepare sub directories
Browse files Browse the repository at this point in the history
refs #3814
  • Loading branch information
nilmerg committed Jun 25, 2019
1 parent bd20607 commit 4d69340
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/Icinga/Web/FileCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,27 @@ protected function filename($file)
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
*
Expand Down

0 comments on commit 4d69340

Please sign in to comment.