while (*next) {
next = strchr(next, '/');
*next = 0;
- if (!CreateDirectory(pathname, NULL))
+ if (!CreateDirectory(pathname, NULL) &&
+ GetLastError() != ERROR_ALREADY_EXISTS)
return MakeErrMsg(ErrMsg,
std::string(pathname) + ": Can't create directory: ");
*next++ = '/';
} else {
// Drop trailing slash.
pathname[len-1] = 0;
- if (!CreateDirectory(pathname, NULL)) {
+ if (!CreateDirectory(pathname, NULL) &&
+ GetLastError() != ERROR_ALREADY_EXISTS) {
return MakeErrMsg(ErrMsg, std::string(pathname) + ": Can't create directory: ");
}
}