private function ensureDirectoryExists($path)
{
$filesystemPath = $this->baseDir . $path;
if (is_file($filesystemPath)) {
throw new UnsupportedOperationException(sprintf('Instances of BodyResource do not support child resources in ' . 'FilesystemRepository. Tried to add a child to %s.', $filesystemPath));
}
if (!is_dir($filesystemPath)) {
mkdir($filesystemPath, 0777, true);
}
}