Add a second output argument to CheckPath nonzero iff the routine creates a new directory.

(cherry picked from commit fd5742a399dca1a125e170123d2125b77e8f5b2a)
Fixed bug.

(cherry picked from commit 8e6df8560462fa19098c6708284460cef958cea1)