kernel32: Add a stub implementation for GetVolumeNameForVolumeMountPoint{A, W}.

This commit is contained in:
Hans Leidekker 2007-01-07 13:08:31 +01:00 committed by Alexandre Julliard
parent a7c9970762
commit 7918c59f86
3 changed files with 83 additions and 6 deletions

View File

@ -649,8 +649,8 @@
@ stdcall GetVersionExW(ptr) @ stdcall GetVersionExW(ptr)
@ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long) @ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long)
@ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long) @ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long)
@ stub GetVolumeNameForVolumeMountPointA @ stdcall GetVolumeNameForVolumeMountPointA(str ptr long)
@ stdcall GetVolumeNameForVolumeMountPointW(wstr long long) @ stdcall GetVolumeNameForVolumeMountPointW(wstr ptr long)
@ stdcall GetVolumePathNameA(str ptr long) @ stdcall GetVolumePathNameA(str ptr long)
@ stdcall GetVolumePathNameW(wstr ptr long) @ stdcall GetVolumePathNameW(wstr ptr long)
# @ stub GetVolumePathNamesForVolumeNameA # @ stub GetVolumePathNamesForVolumeNameA

View File

@ -45,7 +45,51 @@ static void test_query_dos_deviceA(void)
} }
} }
static void test_GetVolumeNameForVolumeMountPointA(void)
{
BOOL ret;
char volume[MAX_PATH], path[] = "c:\\";
DWORD len = sizeof(volume);
ret = GetVolumeNameForVolumeMountPointA(path, volume, 0);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
if (0) { /* these crash on XP */
ret = GetVolumeNameForVolumeMountPointA(path, NULL, len);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
ret = GetVolumeNameForVolumeMountPointA(NULL, volume, len);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
}
ret = GetVolumeNameForVolumeMountPointA(path, volume, len);
ok(ret == TRUE, "GetVolumeNameForVolumeMountPointA failed\n");
}
static void test_GetVolumeNameForVolumeMountPointW(void)
{
BOOL ret;
WCHAR volume[MAX_PATH], path[] = {'c',':','\\',0};
DWORD len = sizeof(volume) / sizeof(WCHAR);
ret = GetVolumeNameForVolumeMountPointW(path, volume, 0);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointA succeeded\n");
if (0) { /* these crash on XP */
ret = GetVolumeNameForVolumeMountPointW(path, NULL, len);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
ret = GetVolumeNameForVolumeMountPointW(NULL, volume, len);
ok(ret == FALSE, "GetVolumeNameForVolumeMountPointW succeeded\n");
}
ret = GetVolumeNameForVolumeMountPointW(path, volume, len);
ok(ret == TRUE, "GetVolumeNameForVolumeMountPointW failed\n");
}
START_TEST(volume) START_TEST(volume)
{ {
test_query_dos_deviceA(); test_query_dos_deviceA();
test_GetVolumeNameForVolumeMountPointA();
test_GetVolumeNameForVolumeMountPointW();
} }

View File

@ -748,14 +748,47 @@ BOOL WINAPI SetVolumeLabelA(LPCSTR root, LPCSTR volname)
/*********************************************************************** /***********************************************************************
* GetVolumeNameForVolumeMountPointW (KERNEL32.@) * GetVolumeNameForVolumeMountPointA (KERNEL32.@)
*/ */
BOOL WINAPI GetVolumeNameForVolumeMountPointW(LPCWSTR str, LPWSTR dst, DWORD size) BOOL WINAPI GetVolumeNameForVolumeMountPointA( LPCSTR path, LPSTR volume, DWORD size )
{ {
FIXME("(%s, %p, %x): stub\n", debugstr_w(str), dst, size); BOOL ret;
return 0; WCHAR volumeW[50], *pathW = NULL;
DWORD len = min( sizeof(volumeW) / sizeof(WCHAR), size );
TRACE("(%s, %p, %x)\n", debugstr_a(path), volume, size);
if (!path || !(pathW = FILE_name_AtoW( path, TRUE )))
return FALSE;
if ((ret = GetVolumeNameForVolumeMountPointW( pathW, volumeW, len )))
FILE_name_WtoA( volumeW, -1, volume, len );
HeapFree( GetProcessHeap(), 0, pathW );
return ret;
} }
/***********************************************************************
* GetVolumeNameForVolumeMountPointW (KERNEL32.@)
*/
BOOL WINAPI GetVolumeNameForVolumeMountPointW( LPCWSTR path, LPWSTR volume, DWORD size )
{
BOOL ret = FALSE;
static const WCHAR fmt[] =
{ '\\','\\','?','\\','V','o','l','u','m','e','{','%','0','2','x','}','\\',0 };
TRACE("(%s, %p, %x)\n", debugstr_w(path), volume, size);
if (!path || !path[0]) return FALSE;
if (size >= sizeof(fmt) / sizeof(WCHAR))
{
/* FIXME: will break when we support volume mounts */
sprintfW( volume, fmt, tolowerW( path[0] ) - 'a' );
ret = TRUE;
}
return ret;
}
/*********************************************************************** /***********************************************************************
* DefineDosDeviceW (KERNEL32.@) * DefineDosDeviceW (KERNEL32.@)