Added missing features in GetFullPathName[A/W]().

svn path=/trunk/; revision=423
This commit is contained in:
Eric Kohl 1999-04-29 23:32:27 +00:00
parent 278a6c540b
commit ddd8467f99

View file

@ -197,7 +197,24 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName,
if (isalpha(lpFileName[0]) && lpFileName[1] == ':') if (isalpha(lpFileName[0]) && lpFileName[1] == ':')
{ {
lstrcpyA(lpBuffer, lpFileName); if (lpFileName[2] == '\\')
{
lstrcpyA(lpBuffer, lpFileName);
}
else
{
CHAR szRoot[4] = "A:\\";
DWORD len;
szRoot[0] = lpFileName[0];
len = GetCurrentDirectoryA(nBufferLength, lpBuffer);
if (lpBuffer[len - 1] != '\\')
{
lpBuffer[len] = '\\';
lpBuffer[len + 1] = 0;
}
lstrcatA(lpBuffer, &lpFileName[2]);
}
} }
else if (lpFileName[0] == '\\') else if (lpFileName[0] == '\\')
{ {
@ -210,8 +227,8 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName,
len = GetCurrentDirectoryA(nBufferLength, lpBuffer); len = GetCurrentDirectoryA(nBufferLength, lpBuffer);
if (lpBuffer[len - 1] != '\\') if (lpBuffer[len - 1] != '\\')
{ {
lpBuffer[len] = '\\'; lpBuffer[len] = '\\';
lpBuffer[len + 1] = 0; lpBuffer[len + 1] = 0;
} }
lstrcatA(lpBuffer, lpFileName); lstrcatA(lpBuffer, lpFileName);
} }
@ -222,90 +239,56 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName,
while ((*p) != 0) while ((*p) != 0)
{ {
DWORD dwDotLen; DWORD dwDotLen;
dwDotLen = GetDotSequenceLengthA (p+1); dwDotLen = GetDotSequenceLengthA (p+1);
DPRINT("DotSequenceLength %u\n", dwDotLen); DPRINT("DotSequenceLength %u\n", dwDotLen);
DPRINT("prev %s p %s\n",prev,p); DPRINT("prev %s p %s\n",prev,p);
if (dwDotLen == 0) if (dwDotLen == 0)
{ {
prev = p; prev = p;
do do
{ {
p++; p++;
} }
while ((*p) != 0 && (*p) != '\\'); while ((*p) != 0 && (*p) != '\\');
} }
else if (dwDotLen == 1) else if (dwDotLen == 1)
{ {
lstrcpyA(p, p+2); lstrcpyA(p, p+2);
} }
else else
{ {
if (dwDotLen > 2) if (dwDotLen > 2)
{ {
int n = dwDotLen - 2; int n = dwDotLen - 2;
while (n > 0) while (n > 0)
{ {
prev--; prev--;
if ((*prev) == '\\') if ((*prev) == '\\')
n--; n--;
if (prev == (lpBuffer+2)) if (prev == (lpBuffer+2))
break; break;
} }
} }
lstrcpyA (prev, p+dwDotLen+1); lstrcpyA (prev, p+dwDotLen+1);
p = prev; p = prev;
if (prev == (lpBuffer+2)) if (prev == (lpBuffer+2))
{ {
prev = NULL; prev = NULL;
} }
else else
{ {
prev--; prev--;
while ((*prev) != '\\') while ((*prev) != '\\')
{ {
prev--; prev--;
} }
} }
} }
#if 0
if (p[1] == '.' && (p[2] == '\\' || p[2] == 0))
{
lstrcpyA(p, p+2);
}
else if (p[1] == '.' && p[2] == '.' && (p[3] == '\\' || p[3] == 0) &&
prev != NULL)
{
lstrcpyA(prev, p+3);
p = prev;
if (prev == (lpBuffer+2))
{
prev = NULL;
}
else
{
prev--;
while ((*prev) != '\\')
{
prev--;
}
}
}
else
{
prev = p;
do
{
p++;
}
while ((*p) != 0 && (*p) != '\\');
}
#endif
} }
if (lpFilePart != NULL) if (lpFilePart != NULL)
@ -321,19 +304,19 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName,
static DWORD GetDotSequenceLengthW (PWSTR p) static DWORD GetDotSequenceLengthW (PWSTR p)
{ {
DWORD dwCount = 0; DWORD dwCount = 0;
for (;;) for (;;)
{ {
if (*p == '.') if (*p == '.')
dwCount++; dwCount++;
else if ((*p == '\\' || *p == '\0') && dwCount) else if ((*p == '\\' || *p == '\0') && dwCount)
return dwCount; return dwCount;
else else
return 0; return 0;
p++; p++;
} }
return 0; return 0;
} }
@ -351,11 +334,28 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName,
if (!lpFileName || !lpBuffer) if (!lpFileName || !lpBuffer)
return 0; return 0;
if (isalpha(lpFileName[0]) && lpFileName[1] == ':') if (isalpha(lpFileName[0]) && lpFileName[1] == L':')
{ {
lstrcpyW(lpBuffer, lpFileName); if (lpFileName[2] == L'\\')
{
lstrcpyW(lpBuffer, lpFileName);
}
else
{
WCHAR szRoot[4] = L"A:\\";
DWORD len;
szRoot[0] = lpFileName[0];
len = GetCurrentDirectoryW(nBufferLength, lpBuffer);
if (lpBuffer[len - 1] != L'\\')
{
lpBuffer[len] = L'\\';
lpBuffer[len + 1] = 0;
}
lstrcatW(lpBuffer, &lpFileName[2]);
}
} }
else if (lpFileName[0] == '\\') else if (lpFileName[0] == L'\\')
{ {
GetCurrentDirectoryW(nBufferLength, lpBuffer); GetCurrentDirectoryW(nBufferLength, lpBuffer);
lstrcpyW(&lpBuffer[2], lpFileName); lstrcpyW(&lpBuffer[2], lpFileName);
@ -366,8 +366,8 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName,
len = GetCurrentDirectoryW(nBufferLength, lpBuffer); len = GetCurrentDirectoryW(nBufferLength, lpBuffer);
if (lpBuffer[len - 1] != L'\\') if (lpBuffer[len - 1] != L'\\')
{ {
lpBuffer[len] = L'\\'; lpBuffer[len] = L'\\';
lpBuffer[len + 1] = 0; lpBuffer[len + 1] = 0;
} }
lstrcatW(lpBuffer, lpFileName); lstrcatW(lpBuffer, lpFileName);
} }
@ -385,87 +385,51 @@ DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName,
DPRINT("prev %w p %w\n",prev,p); DPRINT("prev %w p %w\n",prev,p);
if (dwDotLen == 0) if (dwDotLen == 0)
{ {
prev = p; prev = p;
do do
{ {
p++; p++;
} }
while ((*p) != 0 && (*p) != '\\'); while ((*p) != 0 && (*p) != L'\\');
} }
else if (dwDotLen == 1) else if (dwDotLen == 1)
{ {
lstrcpyW(p, p+2); lstrcpyW(p, p+2);
} }
else else
{ {
if (dwDotLen > 2) if (dwDotLen > 2)
{ {
int n = dwDotLen - 2; int n = dwDotLen - 2;
while (n > 0) while (n > 0)
{ {
prev--; prev--;
if ((*prev) == '\\') if ((*prev) == L'\\')
n--; n--;
if (prev == (lpBuffer+2)) if (prev == (lpBuffer+2))
break; break;
} }
} }
lstrcpyW (prev, p+dwDotLen+1); lstrcpyW (prev, p+dwDotLen+1);
p = prev; p = prev;
if (prev == (lpBuffer+2)) if (prev == (lpBuffer+2))
{ {
prev = NULL; prev = NULL;
} }
else else
{ {
prev--; prev--;
while ((*prev) != '\\') while ((*prev) != L'\\')
{ {
prev--; prev--;
} }
} }
} }
#if 0
DPRINT("prev %w p %w\n",prev,p);
if (p[1] == '.' && (p[2] == '\\' || p[2] == 0))
{
lstrcpyW(p, p+2);
}
else if (p[1] == '.' && p[2] == '.' && (p[3] == '\\' || p[3] == 0) &&
prev != NULL)
{
lstrcpyW(prev, p+3);
p = prev;
if (prev == (lpBuffer+2))
{
prev = NULL;
}
else
{
prev--;
while ((*prev) != '\\')
{
prev--;
}
}
}
else
{
prev = p;
do
{
p++;
}
while ((*p) != 0 && (*p) != '\\');
}
#endif
} }
if (lpFilePart != NULL) if (lpFilePart != NULL)
{ {
(*lpFilePart) = prev + 1; (*lpFilePart) = prev + 1;