added ensure for parent dir.