Hans Leidekker : kernel32:
Add a stub implementation for GetVolumeNameForVolumeMountPoint{A, W}.
Alexandre Julliard
julliard at wine.codeweavers.com
Tue Jan 9 06:10:43 CST 2007
Module: wine
Branch: master
Commit: 7918c59f867e438b1e609010d5057025764693b5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=7918c59f867e438b1e609010d5057025764693b5
Author: Hans Leidekker <hans at it.vu.nl>
Date: Sun Jan 7 13:08:31 2007 +0100
kernel32: Add a stub implementation for GetVolumeNameForVolumeMountPoint{A, W}.
---
dlls/kernel32/kernel32.spec | 4 +-
dlls/kernel32/tests/volume.c | 44 ++++++++++++++++++++++++++++++++++++++++++
dlls/kernel32/volume.c | 41 +++++++++++++++++++++++++++++++++++---
3 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index fa52d1b..0e8a1fc 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -649,8 +649,8 @@
@ stdcall GetVersionExW(ptr)
@ stdcall GetVolumeInformationA(str ptr long ptr ptr ptr ptr long)
@ stdcall GetVolumeInformationW(wstr ptr long ptr ptr ptr ptr long)
-@ stub GetVolumeNameForVolumeMountPointA
-@ stdcall GetVolumeNameForVolumeMountPointW(wstr long long)
+@ stdcall GetVolumeNameForVolumeMountPointA(str ptr long)
+@ stdcall GetVolumeNameForVolumeMountPointW(wstr ptr long)
@ stdcall GetVolumePathNameA(str ptr long)
@ stdcall GetVolumePathNameW(wstr ptr long)
# @ stub GetVolumePathNamesForVolumeNameA
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index b27fa74..e940a4b 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -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)
{
test_query_dos_deviceA();
+ test_GetVolumeNameForVolumeMountPointA();
+ test_GetVolumeNameForVolumeMountPointW();
}
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index f679250..d73e603 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -748,14 +748,47 @@ BOOL WINAPI SetVolumeLabelA(LPCSTR root,
/***********************************************************************
- * 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);
- return 0;
+ BOOL ret;
+ 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.@)
More information about the wine-cvs
mailing list