protected function prepareDirectory($directory, $name)
{
if (!is_dir($directory)) {
if (false === @mkdir($directory, 0777, true)) {
throw new RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, $directory));
}
} elseif (!is_writable($directory)) {
throw new RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $directory));
}
}