Ensure directories exist in several cases