+1 @alasdairhodge about just calling `dir.mkdirs()` always, and checking the directory for successful creation afterwards