Try to create the complete path right away and fall back
to creating all path elements one by one.
Ignore ENOENT errors up until the last element while trying to create each of the path elements in case a restricted file-system is being used where path elements can be hidden or non-accessible.
This also helps to avoid TOCTOU problems and avoids walking the path all the time, providing a nice performance gain, by avoiding syscalls.
Edited by Jeff Fortin