partial implementation of GetVolumePathName
Michael Blakeley
mike at blakeley.com
Mon Jun 5 21:35:10 CDT 2006
-------------- next part --------------
? libs/unicode/libwine_unicode.1.dylib
? libs/wine/libwine.1.dylib
Index: dlls/kernel/volume.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/volume.c,v
retrieving revision 1.37
diff -u -d -b -w -u -r1.37 volume.c
--- dlls/kernel/volume.c 23 May 2006 12:48:03 -0000 1.37
+++ dlls/kernel/volume.c 5 Jun 2006 03:58:55 -0000
@@ -1336,21 +1336,59 @@
}
/***********************************************************************
- * GetVolumePathNameA (KERNEL32.@)
+ * GetVolumePathNameW (KERNEL32.@)
+ *
+ * retrieve the volume mount point for filename
+ * and copy it into volumepathname.
+ *
+ * if there is no volume, return the boot path (eg, "C:")
+ *
*/
-BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD buflen)
+BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen)
{
- FIXME("(%s, %p, %ld), stub!\n", debugstr_a(filename), volumepathname, buflen);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ /* does this look like a dos device name? */
+ if (!filename[0] || filename[1] != ':'
+ || !filename[2] || filename[2] != '\\')
+ {
+ FIXME("(%s, %p, %ld), %s!\n", debugstr_w(filename), volumepathname, buflen,
+ "only handles dos device names");
+ SetLastError( ERROR_INVALID_NAME );
return FALSE;
}
+ FIXME("(%s, %p, %ld), %s!\n", debugstr_w(filename), volumepathname, buflen,
+ "assumes dos device name");
+ lstrcpynW( volumepathname, filename, 4 );
+ return TRUE;
+}
/***********************************************************************
- * GetVolumePathNameW (KERNEL32.@)
+ * GetVolumePathNameA (KERNEL32.@)
+ *
+ * see GetVolumePathNameW
*/
-BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen)
+BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD buflen)
{
- FIXME("(%s, %p, %ld), stub!\n", debugstr_w(filename), volumepathname, buflen);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ BOOL ret;
+ LPCWSTR filenameW = NULL;
+ LPWSTR volumepathnameW;
+ if (filename) {
+ filenameW = FILE_name_AtoW( filename, FALSE );
+ if (!filenameW) {
return FALSE;
}
+ }
+ volumepathnameW = volumepathname
+ ? HeapAlloc(GetProcessHeap(), 0, buflen * sizeof(WCHAR))
+ : NULL;
+ /* rely on GetVolumePathW to call SetLastError, if needed */
+ ret = GetVolumePathNameW(filenameW, volumepathnameW, buflen);
+ if (ret) {
+ if (volumepathnameW) {
+ FILE_name_WtoA(volumepathnameW, -1, volumepathname, buflen);
+ }
+ }
+ HeapFree( GetProcessHeap(), 0, volumepathnameW );
+ return ret;
+}
+
+/* volume.c */
Index: dlls/kernel/tests/volume.c
===================================================================
RCS file: /home/wine/wine/dlls/kernel/tests/volume.c,v
retrieving revision 1.2
diff -u -d -b -w -u -r1.2 volume.c
--- dlls/kernel/tests/volume.c 23 May 2006 12:48:07 -0000 1.2
+++ dlls/kernel/tests/volume.c 5 Jun 2006 03:58:55 -0000
@@ -21,6 +21,7 @@
#include "wine/test.h"
#include "winbase.h"
+#define C_PATH "C:\\"
#define CDROM "CDROM"
#define FLOPPY "FLOPPY"
#define HARDISK "HARDDISK"
@@ -45,7 +46,26 @@
}
}
+static void test_getvolumepathnameA()
+{
+ LPCSTR filename = "C:\\temp\\foo\\bar\\baz";
+ DWORD buflen = 16;
+ LPSTR volumepathname =
+ HeapAlloc(GetProcessHeap(), 0, buflen * sizeof(WCHAR));
+ BOOLEAN ret;
+
+ ret = GetVolumePathNameA(filename, volumepathname, buflen);
+ if (ret) {
+ ok( 0 == strcmp( volumepathname, C_PATH),
+ "expect the string %s, got %s\n", C_PATH, volumepathname );
+ } else {
+ ok( FALSE,
+ "expect the string %s, got error %lu\n", C_PATH, GetLastError() );
+ }
+}
+
START_TEST(volume)
{
test_query_dos_deviceA();
+ test_getvolumepathnameA();
}
Index: dlls/rpcrt4/epm_towers.h
===================================================================
RCS file: /home/wine/wine/dlls/rpcrt4/epm_towers.h,v
retrieving revision 1.1
diff -u -d -b -w -u -r1.1 epm_towers.h
--- dlls/rpcrt4/epm_towers.h 2 Jun 2006 09:56:57 -0000 1.1
+++ dlls/rpcrt4/epm_towers.h 5 Jun 2006 03:58:55 -0000
@@ -51,7 +51,9 @@
typedef unsigned char u_int8;
typedef unsigned short u_int16;
typedef unsigned int u_int32;
+#ifndef _UUID_T
typedef GUID uuid_t;
+#endif
typedef struct
{
More information about the wine-patches
mailing list