Fix the coverity issues

This PR is to resolve issues raised by coverity.

BUG=XWALK-2928
You could simplify this and remove the call to `PathExists`, since `CreateDirectory()` will do nothing if the path is already there.