-static DWORD WINAPI
-get_long_path_name_w32impl (LPCWSTR src, LPWSTR sbuf, DWORD)
-{
- wchar_t *buf1 = (wchar_t *) malloc (32768);
- wchar_t *buf2 = (wchar_t *) malloc (32768);
- wchar_t *ptr;
- const wchar_t *pelem, *next;
- WIN32_FIND_DATAW w32_fd;
- DWORD len;
-
- wcscpy (buf1, src);
- *buf2 = L'\0';
- pelem = src;
- ptr = buf2;
- while (pelem)
- {
- next = pelem;
- if (*next == L'\\')
- {
- wcscat (ptr++, L"\\");
- pelem++;
- if (!*pelem)
- break;
- continue;
- }
- pelem = wcschr (next, L'\\');
- len = pelem ? (pelem++ - next) : wcslen (next);
- wcsncpy (ptr, next, len);
- ptr[len] = L'\0';
- if (next[1] != L':' && wcscmp(next, L".") && wcscmp(next, L".."))
- {
- HANDLE h;
- h = FindFirstFileW (buf2, &w32_fd);
- if (h != INVALID_HANDLE_VALUE)
- {
- wcscpy (ptr, w32_fd.cFileName);
- FindClose (h);
- }
- }
- ptr += wcslen (ptr);
- if (pelem)
- {
- *ptr++ = '\\';
- *ptr = 0;
- }
- }
- if (sbuf)
- wcscpy (sbuf, buf2);
- SetLastError (0);
- len = wcslen (buf2) + (sbuf ? 0 : 1);
- free (buf1);
- free (buf2);
- return len;
-}
-