Replace MAXPATHLEN with FILE_MAX, always allocate if the buffer isn't big enough since creating a truncated directory isn't useful. Having some code-paths only run in an ifdef complicated the code and made it more difficult to follow. Also assert the path doesn't contain ".." directories as they aren't supported.