dir can't be NULL