static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
+static BOOL (WINAPI *pGetVolumePathNameA)(LPCSTR, LPSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameA)(LPCSTR, LPSTR, DWORD, LPDWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameW)(LPCWSTR, LPWSTR, DWORD, LPDWORD);
}
/* Map it to point to the current directory */
- ret = GetCurrentDirectory(sizeof(buf), buf);
+ ret = GetCurrentDirectoryA(sizeof(buf), buf);
ok(ret, "GetCurrentDir\n");
ret = DefineDosDeviceA(0, drivestr, buf);
"GetVolumeNameForVolumeMountPointA failed, wrong error returned, was %d, should be ERROR_FILENAME_EXCED_RANGE\n",
GetLastError());
- /* Try on a arbitrary directory */
+ /* Try on an arbitrary directory */
/* On FAT filesystems it seems that GetLastError() is set to
ERROR_INVALID_FUNCTION. */
ret = pGetVolumeNameForVolumeMountPointA(temp_path, volume, len);
}
/* get windows drive letter and update strings for testing */
- result = GetWindowsDirectory(windowsdir, sizeof(windowsdir));
+ result = GetWindowsDirectoryA(windowsdir, sizeof(windowsdir));
ok(result < sizeof(windowsdir), "windowsdir is abnormally long!\n");
ok(result != 0, "GetWindowsDirectory: error %d\n", GetLastError());
Root_Colon[0] = windowsdir[0];
Root_Slash[0] = windowsdir[0];
Root_UNC[4] = windowsdir[0];
- result = GetCurrentDirectory(MAX_PATH, currentdir);
+ result = GetCurrentDirectoryA(MAX_PATH, currentdir);
ok(result, "GetCurrentDirectory: error %d\n", GetLastError());
/* Note that GetCurrentDir yields no trailing slash for subdirs */
/* check for NO error on no trailing \ when current dir is root dir */
- ret = SetCurrentDirectory(Root_Slash);
+ ret = SetCurrentDirectoryA(Root_Slash);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
NULL, NULL, fs_name_buf, fs_name_len);
ok(ret, "GetVolumeInformationA root failed, last error %u\n", GetLastError());
/* check for error on no trailing \ when current dir is subdir (windows) of queried drive */
- ret = SetCurrentDirectory(windowsdir);
+ ret = SetCurrentDirectoryA(windowsdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
SetLastError(0xdeadbeef);
ret = pGetVolumeInformationA(Root_Colon, vol_name_buf, vol_name_size, NULL,
"GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
/* reset current directory */
- ret = SetCurrentDirectory(currentdir);
+ ret = SetCurrentDirectoryA(currentdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
if (toupper(currentdir[0]) == toupper(windowsdir[0])) {
/* C:\windows becomes the current directory on drive C: */
/* Note that paths to subdirs are stored without trailing slash, like what GetCurrentDir yields. */
- ret = SetEnvironmentVariable(Root_Env, windowsdir);
+ ret = SetEnvironmentVariableA(Root_Env, windowsdir);
ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
- ret = SetCurrentDirectory(windowsdir);
+ ret = SetCurrentDirectoryA(windowsdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
- ret = SetCurrentDirectory(currentdir);
+ ret = SetCurrentDirectoryA(currentdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
/* windows dir is current on the root drive, call fails */
NULL, NULL, fs_name_buf, fs_name_len);
ok(ret, "GetVolumeInformationA with \\ failed, last error %u\n", GetLastError());
- ret = SetCurrentDirectory(Root_Slash);
+ ret = SetCurrentDirectoryA(Root_Slash);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
- ret = SetCurrentDirectory(currentdir);
+ ret = SetCurrentDirectoryA(currentdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
/* windows dir is STILL CURRENT on root drive; the call fails as before, */
"GetVolumeInformationA did%s fail, last error %u\n", ret ? " not":"", GetLastError());
/* Now C:\ becomes the current directory on drive C: */
- ret = SetEnvironmentVariable(Root_Env, Root_Slash); /* set =C:=C:\ */
+ ret = SetEnvironmentVariableA(Root_Env, Root_Slash); /* set =C:=C:\ */
ok(ret, "SetEnvironmentVariable %s failed\n", Root_Env);
/* \ is current on root drive, call succeeds */
ok(ret, "GetVolumeInformationA failed, last error %u\n", GetLastError());
/* again, SetCurrentDirectory on another drive does not matter */
- ret = SetCurrentDirectory(Root_Slash);
+ ret = SetCurrentDirectoryA(Root_Slash);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
- ret = SetCurrentDirectory(currentdir);
+ ret = SetCurrentDirectoryA(currentdir);
ok(ret, "SetCurrentDirectory: error %d\n", GetLastError());
/* \ is current on root drive, call succeeds */
}
/*get windows drive letter and update strings for testing */
- ret = GetWindowsDirectory( windowsdir, sizeof(windowsdir) );
+ ret = GetWindowsDirectoryA( windowsdir, sizeof(windowsdir) );
ok(ret < sizeof(windowsdir), "windowsdir is abnormally long!\n");
ok(ret != 0, "GetWindowsDirecory: error %d\n", GetLastError());
path[0] = windowsdir[0];
CloseHandle( handle );
}
+static void test_GetVolumePathNameA(void)
+{
+ BOOL ret;
+ char volume[MAX_PATH];
+ char expected[] = "C:\\", pathC1[] = "C:\\", pathC2[] = "C::";
+ DWORD error;
+
+ if (!pGetVolumePathNameA)
+ {
+ win_skip("required functions not found\n");
+ return;
+ }
+
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA(NULL, NULL, 0);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_INVALID_PARAMETER
+ || broken( error == 0xdeadbeef) /* <=XP */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", error);
+
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA("", NULL, 0);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_INVALID_PARAMETER
+ || broken( error == 0xdeadbeef) /* <=XP */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", error);
+
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA(pathC1, NULL, 0);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_INVALID_PARAMETER
+ || broken(error == ERROR_FILENAME_EXCED_RANGE) /* <=XP */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", error);
+
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA(pathC1, volume, 0);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_INVALID_PARAMETER
+ || broken(error == ERROR_FILENAME_EXCED_RANGE ) /* <=XP */,
+ "expected ERROR_INVALID_PARAMETER got %u\n", error);
+
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA(pathC1, volume, 1);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_FILENAME_EXCED_RANGE, "expected ERROR_FILENAME_EXCED_RANGE got %u\n", error);
+
+ volume[0] = '\0';
+ ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
+ ok(ret, "expected success\n");
+ ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", pathC1, volume);
+
+ pathC1[0] = tolower(pathC1[0]);
+ volume[0] = '\0';
+ ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
+ ok(ret, "expected success\n");
+todo_wine
+ ok(!strcmp(expected, volume) || broken(!strcasecmp(expected, volume)) /* <=XP */,
+ "expected name '%s', returned '%s'\n", expected, volume);
+
+ volume[0] = '\0';
+ ret = pGetVolumePathNameA(pathC2, volume, sizeof(volume));
+todo_wine
+ ok(ret, "expected success\n");
+todo_wine
+ ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", expected, volume);
+
+ /* test an invalid path */
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA("\\\\$$$", volume, 1);
+ error = GetLastError();
+ ok(!ret, "expected failure\n");
+ ok(error == ERROR_INVALID_NAME || broken(ERROR_FILENAME_EXCED_RANGE) /* <=2000 */,
+ "expected ERROR_INVALID_NAME got %u\n", error);
+}
+
static void test_GetVolumePathNamesForVolumeNameA(void)
{
BOOL ret;
WCHAR volume[MAX_PATH], buffer[MAX_PATH];
DWORD len, error;
+#ifdef __REACTOS__
+ /* due to failing all calls to GetVolumeNameForVolumeMountPointW, this
+ * buffer never gets initialized and could cause a buffer overflow later */
+ volume[0] = 0;
+#endif /* __REACTOS__ */
+
if (!pGetVolumePathNamesForVolumeNameW || !pGetVolumeNameForVolumeMountPointW)
{
win_skip("required functions not found\n");
/* Test whether this ioctl is supported */
ret = DeviceIoControl(handle, IOCTL_DVD_READ_STRUCTURE, &dvdReadStructure, sizeof(DVD_READ_STRUCTURE),
&completeDvdLayerDescriptor, sizeof(struct COMPLETE_DVD_LAYER_DESCRIPTOR), &nbBytes, NULL);
- if ((!ret && GetLastError() == ERROR_INVALID_FUNCTION)
- || (!ret && GetLastError() == ERROR_NOT_SUPPORTED))
- {
- skip("IOCTL_DVD_READ_STRUCTURE not supported\n");
- return;
- }
- ok(ret || broken(GetLastError() == ERROR_NOT_READY) || broken(GetLastError() == ERROR_INVALID_PARAMETER),
- "IOCTL_DVD_READ_STRUCTURE (DvdPhysicalDescriptor) failed, last error = %u\n", GetLastError());
if(!ret)
+ {
+ skip("IOCTL_DVD_READ_STRUCTURE not supported: %u\n", GetLastError());
return;
+ }
/* Confirm there is always a header before the actual data */
ok( completeDvdLayerDescriptor.Header.Length == 0x0802, "Length is 0x%04x instead of 0x0802\n", completeDvdLayerDescriptor.Header.Length);
pGetLogicalDriveStringsA = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsA");
pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
+ pGetVolumePathNameA = (void *) GetProcAddress(hdll, "GetVolumePathNameA");
pGetVolumePathNamesForVolumeNameA = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameA");
pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
test_query_dos_deviceA();
test_define_dos_deviceA();
test_FindFirstVolume();
+ test_GetVolumePathNameA();
test_GetVolumeNameForVolumeMountPointA();
test_GetVolumeNameForVolumeMountPointW();
test_GetLogicalDriveStringsA();