Make sure makedirs: True accounts for case where a trailing slash exists
Merge pull request #3829 from tony/file.directory-makedirs-fix

Make sure makedirs: True accounts for case where a trailing slash exists