add trailing slash to dir if not given.