fix mkdir on a path ending in a slash; fixes #2263 and #2258