diff --git a/lldb/include/lldb/Host/windows/PosixApi.h b/lldb/include/lldb/Host/windows/PosixApi.h --- a/lldb/include/lldb/Host/windows/PosixApi.h +++ b/lldb/include/lldb/Host/windows/PosixApi.h @@ -98,7 +98,6 @@ // custom implementations. int vasprintf(char **ret, const char *fmt, va_list ap); char *strcasestr(const char *s, const char *find); -char *realpath(const char *name, char *resolved); #ifdef _MSC_VER diff --git a/lldb/source/Host/windows/Windows.cpp b/lldb/source/Host/windows/Windows.cpp --- a/lldb/source/Host/windows/Windows.cpp +++ b/lldb/source/Host/windows/Windows.cpp @@ -82,89 +82,6 @@ return const_cast(s); } -char *realpath(const char *name, char *resolved) { - char *retname = NULL; - - /* SUSv3 says we must set `errno = EINVAL', and return NULL, - * if `name' is passed as a NULL pointer. - */ - if (name == NULL) { - errno = EINVAL; - return NULL; - } - - /* Otherwise, `name' must refer to a readable filesystem object, - * if we are going to resolve its absolute path name. - */ - wchar_t wideNameBuffer[PATH_MAX]; - wchar_t *wideName = wideNameBuffer; - if (!utf8ToWide(name, wideName, PATH_MAX)) { - errno = EINVAL; - return NULL; - } - - if (_waccess(wideName, 4) != 0) - return NULL; - - /* If `name' didn't point to an existing entity, - * then we don't get to here; we simply fall past this block, - * returning NULL, with `errno' appropriately set by `access'. - * - * When we _do_ get to here, then we can use `_fullpath' to - * resolve the full path for `name' into `resolved', but first, - * check that we have a suitable buffer, in which to return it. - */ - - if ((retname = resolved) == NULL) { - /* Caller didn't give us a buffer, so we'll exercise the - * option granted by SUSv3, and allocate one. - * - * `_fullpath' would do this for us, but it uses `malloc', and - * Microsoft's implementation doesn't set `errno' on failure. - * If we don't do this explicitly ourselves, then we will not - * know if `_fullpath' fails on `malloc' failure, or for some - * other reason, and we want to set `errno = ENOMEM' for the - * `malloc' failure case. - */ - - retname = (char *)malloc(PATH_MAX); - if (retname == NULL) { - errno = ENOMEM; - return NULL; - } - } - - /* Otherwise, when we do have a valid buffer, - * `_fullpath' should only fail if the path name is too long. - */ - - wchar_t wideFullPathBuffer[PATH_MAX]; - wchar_t *wideFullPath; - if ((wideFullPath = _wfullpath(wideFullPathBuffer, wideName, PATH_MAX)) == - NULL) { - errno = ENAMETOOLONG; - return NULL; - } - - // Do a LongPath<->ShortPath roundtrip so that case is resolved by OS - // FIXME: Check for failure - size_t initialLength = wcslen(wideFullPath); - GetShortPathNameW(wideFullPath, wideNameBuffer, PATH_MAX); - GetLongPathNameW(wideNameBuffer, wideFullPathBuffer, initialLength + 1); - - // Convert back to UTF-8 - if (!wideToUtf8(wideFullPathBuffer, retname, PATH_MAX)) { - errno = EINVAL; - return NULL; - } - - // Force drive to be upper case - if (retname[1] == ':') - retname[0] = toupper(retname[0]); - - return retname; -} - #ifdef _MSC_VER char *basename(char *path) {