add mode argument for createDir