Commit 9db754fe authored by Stefan Leichter's avatar Stefan Leichter Committed by Alexandre Julliard

setupapi: Implement SetupGetInfFileListW.

parent fddabcca
......@@ -1454,8 +1454,133 @@ BOOL WINAPI SetupInstallServicesFromInfSectionA( HINF Inf, PCSTR SectionName, DW
BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
DWORD insize, PDWORD outsize)
{
FIXME("(%s %d %p %d %p) stub\n", debugstr_w(dir), style, buffer, insize, outsize);
if(buffer) buffer[0] = 0;
if(outsize) *outsize = 1;
static WCHAR inf[] = {'\\','*','.','i','n','f',0 };
WCHAR *filter, *fullname = NULL, *ptr = buffer;
DWORD dir_len, name_len = 20, size ;
WIN32_FIND_DATAW finddata;
HANDLE hdl;
if (style & ~( INF_STYLE_OLDNT | INF_STYLE_WIN4 |
INF_STYLE_CACHE_ENABLE | INF_STYLE_CACHE_DISABLE ))
{
FIXME( "unknown inf_style(s) 0x%x\n",
style & ~( INF_STYLE_OLDNT | INF_STYLE_WIN4 |
INF_STYLE_CACHE_ENABLE | INF_STYLE_CACHE_DISABLE ));
if( outsize ) *outsize = 1;
return TRUE;
}
if ((style & ( INF_STYLE_OLDNT | INF_STYLE_WIN4 )) == INF_STYLE_NONE)
{
FIXME( "inf_style INF_STYLE_NONE not handled\n" );
if( outsize ) *outsize = 1;
return TRUE;
}
if (style & ( INF_STYLE_CACHE_ENABLE | INF_STYLE_CACHE_DISABLE ))
FIXME("ignored inf_style(s) %s %s\n",
( style & INF_STYLE_CACHE_ENABLE ) ? "INF_STYLE_CACHE_ENABLE" : "",
( style & INF_STYLE_CACHE_DISABLE ) ? "INF_STYLE_CACHE_DISABLE" : "");
if( dir )
{
DWORD att;
DWORD msize;
dir_len = strlenW( dir );
if ( !dir_len ) return FALSE;
msize = ( 7 + dir_len ) * sizeof( WCHAR ); /* \\*.inf\0 */
filter = HeapAlloc( GetProcessHeap(), 0, msize );
if( !filter )
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
strcpyW( filter, dir );
if ( '\\' == filter[dir_len - 1] )
filter[--dir_len] = 0;
att = GetFileAttributesW( filter );
if (att != INVALID_FILE_ATTRIBUTES && !(att & FILE_ATTRIBUTE_DIRECTORY))
{
HeapFree( GetProcessHeap(), 0, filter );
SetLastError( ERROR_DIRECTORY );
return FALSE;
}
}
else
{
WCHAR infdir[] = {'\\','i','n','f',0 };
DWORD msize;
dir_len = GetWindowsDirectoryW( NULL, 0 );
msize = ( 7 + 4 + dir_len ) * sizeof( WCHAR );
filter = HeapAlloc( GetProcessHeap(), 0, msize );
if( !filter )
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
GetWindowsDirectoryW( filter, msize );
strcatW( filter, infdir );
}
strcatW( filter, inf );
hdl = FindFirstFileW( filter , &finddata );
if ( hdl == INVALID_HANDLE_VALUE )
{
if( outsize ) *outsize = 1;
HeapFree( GetProcessHeap(), 0, filter );
return TRUE;
}
size = 1;
do
{
static const WCHAR key[] =
{'S','i','g','n','a','t','u','r','e',0 };
static const WCHAR section[] =
{'V','e','r','s','i','o','n',0 };
static const WCHAR sig_win4_1[] =
{'$','C','h','i','c','a','g','o','$',0 };
static const WCHAR sig_win4_2[] =
{'$','W','I','N','D','O','W','S',' ','N','T','$',0 };
WCHAR signature[ MAX_PATH ];
BOOL valid = FALSE;
DWORD len = strlenW( finddata.cFileName );
if (!fullname || ( name_len < len ))
{
name_len = ( name_len < len ) ? len : name_len;
HeapFree( GetProcessHeap(), 0, fullname );
fullname = HeapAlloc( GetProcessHeap(), 0,
( 2 + dir_len + name_len) * sizeof( WCHAR ));
if( !fullname )
{
HeapFree( GetProcessHeap(), 0, filter );
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
strcpyW( fullname, filter );
}
fullname[ dir_len + 1] = 0; /* keep '\\' */
strcatW( fullname, finddata.cFileName );
if (!GetPrivateProfileStringW( section, key, NULL, signature, MAX_PATH, fullname ))
signature[0] = 0;
if( INF_STYLE_OLDNT & style )
valid = strcmpiW( sig_win4_1, signature ) &&
strcmpiW( sig_win4_2, signature );
if( INF_STYLE_WIN4 & style )
valid = valid || !strcmpiW( sig_win4_1, signature ) ||
!strcmpiW( sig_win4_2, signature );
if( valid )
{
size += 1 + strlenW( finddata.cFileName );
if( ptr && insize >= size )
{
strcpyW( ptr, finddata.cFileName );
ptr += 1 + strlenW( finddata.cFileName );
*ptr = 0;
}
}
}
while( FindNextFileW( hdl, &finddata ));
FindClose( hdl );
HeapFree( GetProcessHeap(), 0, fullname );
HeapFree( GetProcessHeap(), 0, filter );
if( outsize ) *outsize = size;
return TRUE;
}
......@@ -515,7 +515,6 @@ static void test_inffilelist(void)
outsize = 0;
SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
todo_wine
ok(!ret, "expected SetupGetInfFileListW to fail!\n");
/* create a private directory, the temp directory may contain some
......@@ -528,7 +527,7 @@ static void test_inffilelist(void)
}
if (!CreateDirectoryA(dirA, NULL ))
{
win_skip("CreateDirectoryA failed with error %d\n", GetLastError());
win_skip("CreateDirectoryA(%s) failed with error %d\n", dirA, GetLastError());
return;
}
if (!SetCurrentDirectoryA(dirA))
......@@ -548,7 +547,6 @@ static void test_inffilelist(void)
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
ok(outsize == 1, "expected required buffersize to be 1, got %d\n", outsize);
todo_wine
ok(ERROR_PATH_NOT_FOUND == GetLastError(),
"expected error ERROR_PATH_NOT_FOUND, got %d\n", GetLastError());
......@@ -563,9 +561,7 @@ static void test_inffilelist(void)
outsize = 0xffffffff;
SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
todo_wine
ok(!ret, "expected SetupGetInfFileListW to fail!\n");
todo_wine
ok(ERROR_DIRECTORY == GetLastError(),
"expected error ERROR_DIRECTORY, got %d\n", GetLastError());
......@@ -575,9 +571,7 @@ static void test_inffilelist(void)
dir[lstrlenW(dir)] = '\\';
SetLastError(0xdeadbeef);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, NULL, 0, &outsize);
todo_wine
ok(!ret, "expected SetupGetInfFileListW to fail!\n");
todo_wine
ok(ERROR_DIRECTORY == GetLastError(),
"expected error ERROR_DIRECTORY, got %d\n", GetLastError());
......@@ -587,7 +581,6 @@ static void test_inffilelist(void)
expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
todo_wine
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
......@@ -599,7 +592,6 @@ static void test_inffilelist(void)
create_inf_file(inffile2, inf2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
todo_wine
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
......@@ -612,7 +604,6 @@ static void test_inffilelist(void)
expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListW(dir, INF_STYLE_WIN4, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
todo_wine
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
......@@ -624,7 +615,6 @@ static void test_inffilelist(void)
expected = 2 + strlen(invalid_inf);
ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT, buffer, MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
todo_wine
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
......@@ -636,7 +626,6 @@ static void test_inffilelist(void)
ret = pSetupGetInfFileListW(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer,
MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListW to succeed!\n");
todo_wine
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenW(p) && (outsize > (p - buffer)); p+=lstrlenW(p) + 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment