mirror of
https://github.com/reactos/reactos.git
synced 2025-01-10 16:18:16 +00:00
- Implement GetVolumePathNameA/W
svn path=/trunk/; revision=39431
This commit is contained in:
parent
286adffc4b
commit
fb23e17854
2 changed files with 138 additions and 31 deletions
|
@ -1179,4 +1179,142 @@ FindVolumeClose(
|
|||
return RtlFreeHeap(GetProcessHeap(), 0, hFindVolume);
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetVolumePathNameA(LPCSTR lpszFileName,
|
||||
LPSTR lpszVolumePathName,
|
||||
DWORD cchBufferLength)
|
||||
{
|
||||
PWCHAR FileNameW = NULL;
|
||||
WCHAR VolumePathName[MAX_PATH];
|
||||
BOOL Result;
|
||||
|
||||
if (lpszFileName)
|
||||
{
|
||||
if (!(FileNameW = FilenameA2W(lpszFileName, FALSE)))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Result = GetVolumePathNameW(FileNameW, VolumePathName, cchBufferLength);
|
||||
|
||||
if (Result)
|
||||
FilenameW2A_N(lpszVolumePathName, MAX_PATH, VolumePathName, -1);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetVolumePathNameW(LPCWSTR lpszFileName,
|
||||
LPWSTR lpszVolumePathName,
|
||||
DWORD cchBufferLength)
|
||||
{
|
||||
DWORD PathLength;
|
||||
UNICODE_STRING UnicodeFilePath;
|
||||
LPWSTR FilePart;
|
||||
PWSTR FullFilePath, FilePathName;
|
||||
ULONG PathSize;
|
||||
WCHAR VolumeName[MAX_PATH];
|
||||
DWORD ErrorCode;
|
||||
BOOL Result = FALSE;
|
||||
|
||||
if (!(PathLength = GetFullPathNameW(lpszFileName, 0, NULL, NULL)))
|
||||
{
|
||||
return Result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PathLength = PathLength + 10;
|
||||
PathSize = PathLength * sizeof(WCHAR);
|
||||
|
||||
if (!(FullFilePath = RtlAllocateHeap(RtlGetProcessHeap(), 0, PathSize)))
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return Result;
|
||||
}
|
||||
|
||||
if (!GetFullPathNameW(lpszFileName, PathLength, FullFilePath, &FilePart))
|
||||
{
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
|
||||
return Result;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
|
||||
|
||||
if (UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] != '\\')
|
||||
{
|
||||
UnicodeFilePath.Length += sizeof(WCHAR);
|
||||
UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] = '\\';
|
||||
UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
|
||||
}
|
||||
|
||||
if (!(FilePathName = RtlAllocateHeap(RtlGetProcessHeap(), 0, PathSize)))
|
||||
{
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return Result;
|
||||
}
|
||||
|
||||
while (!GetVolumeNameForVolumeMountPointW(UnicodeFilePath.Buffer,
|
||||
VolumeName,
|
||||
MAX_PATH))
|
||||
{
|
||||
if (((UnicodeFilePath.Length == 4) && (UnicodeFilePath.Buffer[0] == '\\') &&
|
||||
(UnicodeFilePath.Buffer[1] == '\\')) || ((UnicodeFilePath.Length == 6) &&
|
||||
(UnicodeFilePath.Buffer[1] == ':')))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
UnicodeFilePath.Length -= sizeof(WCHAR);
|
||||
UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
|
||||
|
||||
memcpy(FilePathName, UnicodeFilePath.Buffer, UnicodeFilePath.Length);
|
||||
FilePathName[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
|
||||
|
||||
if (!GetFullPathNameW(FilePathName, PathLength, FullFilePath, &FilePart))
|
||||
{
|
||||
goto Cleanup2;
|
||||
}
|
||||
|
||||
if (!FilePart)
|
||||
{
|
||||
RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
|
||||
UnicodeFilePath.Length += sizeof(WCHAR);
|
||||
UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR) - 1] = '\\';
|
||||
UnicodeFilePath.Buffer[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
FilePart[0] = '\0';
|
||||
RtlInitUnicodeString(&UnicodeFilePath, FullFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
if (UnicodeFilePath.Length > (cchBufferLength * sizeof(WCHAR)) - sizeof(WCHAR))
|
||||
{
|
||||
ErrorCode = ERROR_FILENAME_EXCED_RANGE;
|
||||
goto Cleanup1;
|
||||
}
|
||||
|
||||
memcpy(lpszVolumePathName, UnicodeFilePath.Buffer, UnicodeFilePath.Length);
|
||||
lpszVolumePathName[UnicodeFilePath.Length / sizeof(WCHAR)] = '\0';
|
||||
|
||||
Result = TRUE;
|
||||
goto Cleanup2;
|
||||
|
||||
Cleanup1:
|
||||
SetLastError(ErrorCode);
|
||||
Cleanup2:
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FullFilePath);
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FilePathName);
|
||||
return Result;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -624,22 +624,6 @@ GetFirmwareEnvironmentVariableW(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetVolumePathNameW(
|
||||
LPCWSTR lpszFileName,
|
||||
LPWSTR lpszVolumePathName,
|
||||
DWORD cchBufferLength
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
@ -766,21 +750,6 @@ GetFirmwareEnvironmentVariableA(
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
GetVolumePathNameA(
|
||||
LPCSTR lpszFileName,
|
||||
LPSTR lpszVolumePathName,
|
||||
DWORD cchBufferLength
|
||||
)
|
||||
{
|
||||
STUB;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* @unimplemented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue