Create subdirectories if necessary.

Passes the test on OS X.