added ensureDir()