kernel32: Fix last error code in GetVolumeInformationW when an explicit subdir is requested.

This commit is contained in:
Alexandre Julliard 2010-10-20 12:29:45 +02:00
parent 357b50600b
commit 1455604704
2 changed files with 8 additions and 2 deletions

View File

@ -435,7 +435,7 @@ static void test_GetVolumeInformationA(void)
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size, ret = pGetVolumeInformationA(windowsdir, vol_name_buf, vol_name_size,
&vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len); &vol_serial_num, &max_comp_len, &fs_flags, fs_name_buf, fs_name_len);
todo_wine ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT || ok(!ret && (GetLastError()==ERROR_DIR_NOT_ROOT ||
broken(GetLastError()==ERROR_BAD_PATHNAME/* win9x */)), broken(GetLastError()==ERROR_BAD_PATHNAME/* win9x */)),
"GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError()); "GetVolumeInformationA did%s fail, root=%s, last error=%u\n", ret ? " not":"", windowsdir, GetLastError());
/* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */ /* A subdir with trailing \ yields DIR_NOT_ROOT instead of INVALID_NAME */

View File

@ -568,7 +568,13 @@ BOOL WINAPI GetVolumeInformationW( LPCWSTR root, LPWSTR label, DWORD label_len,
p = memchrW( nt_name.Buffer + 4, '\\', (nt_name.Length - 4) / sizeof(WCHAR) ); p = memchrW( nt_name.Buffer + 4, '\\', (nt_name.Length - 4) / sizeof(WCHAR) );
if (p != nt_name.Buffer + nt_name.Length / sizeof(WCHAR) - 1) if (p != nt_name.Buffer + nt_name.Length / sizeof(WCHAR) - 1)
{ {
SetLastError( ERROR_INVALID_NAME ); /* check if root contains an explicit subdir */
if (root[0] && root[1] == ':') root += 2;
while (*root == '\\') root++;
if (strchrW( root, '\\' ))
SetLastError( ERROR_DIR_NOT_ROOT );
else
SetLastError( ERROR_INVALID_NAME );
goto done; goto done;
} }