mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
Fixes to GetFullPathNameA and RtlGetFullPathName_U by Tim Jobling
svn path=/trunk/; revision=4648
This commit is contained in:
parent
4ac8de4791
commit
4d7b93456f
2 changed files with 51 additions and 40 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: dir.c,v 1.35 2003/03/09 21:39:17 hbirr Exp $
|
/* $Id: dir.c,v 1.36 2003/05/06 06:49:57 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -321,6 +321,7 @@ GetFullPathNameA (
|
||||||
PWSTR FilePartU;
|
PWSTR FilePartU;
|
||||||
ULONG BufferLength;
|
ULONG BufferLength;
|
||||||
ULONG Offset;
|
ULONG Offset;
|
||||||
|
DWORD FullNameLen;
|
||||||
|
|
||||||
DPRINT("GetFullPathNameA(lpFileName %s, nBufferLength %d, lpBuffer %p, "
|
DPRINT("GetFullPathNameA(lpFileName %s, nBufferLength %d, lpBuffer %p, "
|
||||||
"lpFilePart %p)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart);
|
"lpFilePart %p)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart);
|
||||||
|
@ -351,16 +352,21 @@ GetFullPathNameA (
|
||||||
FullName.Length = 0;
|
FullName.Length = 0;
|
||||||
FullName.Buffer = lpBuffer;
|
FullName.Buffer = lpBuffer;
|
||||||
|
|
||||||
RtlUnicodeStringToAnsiString (&FullName,
|
if (lpBuffer != NULL )
|
||||||
&FullNameU,
|
|
||||||
FALSE);
|
|
||||||
|
|
||||||
if (lpFilePart != NULL)
|
|
||||||
{
|
{
|
||||||
Offset = (ULONG)(FilePartU - FullNameU.Buffer);
|
RtlUnicodeStringToAnsiString (&FullName,
|
||||||
*lpFilePart = FullName.Buffer + Offset;
|
&FullNameU,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
|
if (lpFilePart != NULL)
|
||||||
|
{
|
||||||
|
Offset = (ULONG)(FilePartU - FullNameU.Buffer);
|
||||||
|
*lpFilePart = FullName.Buffer + Offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FullNameLen = FullNameU.Length / sizeof(WCHAR);
|
||||||
|
|
||||||
RtlFreeHeap (RtlGetProcessHeap (),
|
RtlFreeHeap (RtlGetProcessHeap (),
|
||||||
0,
|
0,
|
||||||
FullNameU.Buffer);
|
FullNameU.Buffer);
|
||||||
|
@ -368,7 +374,7 @@ GetFullPathNameA (
|
||||||
DPRINT("lpBuffer %s lpFilePart %s Length %ld\n",
|
DPRINT("lpBuffer %s lpFilePart %s Length %ld\n",
|
||||||
lpBuffer, lpFilePart, FullName.Length);
|
lpBuffer, lpFilePart, FullName.Length);
|
||||||
|
|
||||||
return FullName.Length;
|
return FullNameLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: path.c,v 1.17 2003/03/23 10:49:19 hbirr Exp $
|
/* $Id: path.c,v 1.18 2003/05/06 06:49:57 gvg Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -464,7 +464,6 @@ RtlSetCurrentDirectory_U(PUNICODE_STRING name)
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ULONG STDCALL
|
ULONG STDCALL
|
||||||
RtlGetFullPathName_U(PWSTR DosName,
|
RtlGetFullPathName_U(PWSTR DosName,
|
||||||
ULONG size,
|
ULONG size,
|
||||||
|
@ -478,6 +477,7 @@ RtlGetFullPathName_U(PWSTR DosName,
|
||||||
UNICODE_STRING usvar, pfx;
|
UNICODE_STRING usvar, pfx;
|
||||||
PCURDIR cd;
|
PCURDIR cd;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
WCHAR TempFullPathName[MAX_PATH+2] = L"";
|
||||||
|
|
||||||
DPRINT("RtlGetFullPathName_U %S %ld %p %p\n",
|
DPRINT("RtlGetFullPathName_U %S %ld %p %p\n",
|
||||||
DosName, size, buf, FilePart);
|
DosName, size, buf, FilePart);
|
||||||
|
@ -541,7 +541,7 @@ CHECKPOINT;
|
||||||
if (drive == towupper (cd->DosPath.Buffer[0]))
|
if (drive == towupper (cd->DosPath.Buffer[0]))
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
wcscpy (buf, cd->DosPath.Buffer);
|
wcscpy (TempFullPathName, cd->DosPath.Buffer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -550,8 +550,8 @@ CHECKPOINT;
|
||||||
usvar.MaximumLength = 8;
|
usvar.MaximumLength = 8;
|
||||||
usvar.Buffer = var;
|
usvar.Buffer = var;
|
||||||
pfx.Length = 0;
|
pfx.Length = 0;
|
||||||
pfx.MaximumLength = size;
|
pfx.MaximumLength = MAX_PATH;
|
||||||
pfx.Buffer = buf;
|
pfx.Buffer = TempFullPathName;
|
||||||
Status = RtlQueryEnvironmentVariable_U (NULL,
|
Status = RtlQueryEnvironmentVariable_U (NULL,
|
||||||
&usvar,
|
&usvar,
|
||||||
&pfx);
|
&pfx);
|
||||||
|
@ -561,21 +561,21 @@ CHECKPOINT;
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
if (Status == STATUS_BUFFER_TOO_SMALL)
|
if (Status == STATUS_BUFFER_TOO_SMALL)
|
||||||
return pfx.Length + len * 2 + 2;
|
return pfx.Length + len * 2 + 2;
|
||||||
swprintf (buf, L"%c:\\", drive);
|
swprintf (TempFullPathName, L"%c:\\", drive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: /* \xxx */
|
case 4: /* \xxx */
|
||||||
wcsncpy (buf, cd->DosPath.Buffer, 2);
|
wcsncpy (TempFullPathName, cd->DosPath.Buffer, 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: /* xxx */
|
case 5: /* xxx */
|
||||||
wcscpy (buf, cd->DosPath.Buffer);
|
wcscpy (TempFullPathName, cd->DosPath.Buffer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7: /* \\. */
|
case 7: /* \\. */
|
||||||
wcscpy (buf, L"\\\\.\\");
|
wcscpy (TempFullPathName, L"\\\\.\\");
|
||||||
len = 0;
|
len = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -583,41 +583,46 @@ CHECKPOINT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("buf \'%S\' DosName \'%S\' len %ld\n", buf, DosName, len);
|
DPRINT("TempFullPathName \'%S\' DosName \'%S\' len %ld\n", TempFullPathName, DosName, len);
|
||||||
/* add dosname to prefix */
|
/* add dosname to prefix */
|
||||||
wcsncat (buf, DosName, len);
|
wcsncat (TempFullPathName, DosName, len);
|
||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
/* replace slashes */
|
/* replace slashes */
|
||||||
for (wcs = buf; *wcs; wcs++)
|
for (wcs = TempFullPathName; *wcs; wcs++)
|
||||||
if (*wcs == L'/')
|
if (*wcs == L'/')
|
||||||
*wcs = L'\\';
|
*wcs = L'\\';
|
||||||
|
|
||||||
len = wcslen (buf);
|
len = wcslen (TempFullPathName);
|
||||||
if (len < 3 && buf[len-1] == L':')
|
if (len < 3 && buf[len-1] == L':')
|
||||||
wcscat (buf, L"\\");
|
wcscat (TempFullPathName, L"\\");
|
||||||
|
|
||||||
DPRINT("buf \'%S\'\n", buf);
|
DPRINT("TempFullPathName \'%S\'\n", TempFullPathName);
|
||||||
RtlpEatPath (buf);
|
RtlpEatPath (TempFullPathName);
|
||||||
DPRINT("buf \'%S\'\n", buf);
|
DPRINT("TempFullPathName \'%S\'\n", TempFullPathName);
|
||||||
|
|
||||||
len = wcslen (buf);
|
len = wcslen (TempFullPathName);
|
||||||
|
|
||||||
/* find file part */
|
|
||||||
if (FilePart)
|
|
||||||
{
|
|
||||||
for (wcs = buf + len - 1; wcs >= buf; wcs--)
|
|
||||||
{
|
|
||||||
if (*wcs == L'\\')
|
|
||||||
{
|
|
||||||
*FilePart = wcs + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RtlReleasePebLock();
|
RtlReleasePebLock();
|
||||||
|
|
||||||
|
if (len < (size / sizeof(WCHAR)))
|
||||||
|
{
|
||||||
|
wcsncpy(buf, TempFullPathName, size / sizeof(WCHAR));
|
||||||
|
|
||||||
|
/* find file part */
|
||||||
|
if (FilePart)
|
||||||
|
{
|
||||||
|
for (wcs = buf + len - 1; wcs >= buf; wcs--)
|
||||||
|
{
|
||||||
|
if (*wcs == L'\\')
|
||||||
|
{
|
||||||
|
*FilePart = wcs + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return len * sizeof(WCHAR);
|
return len * sizeof(WCHAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue