Also be sure dirname exists