Commit 05a308a8 authored by Stefan Leichter's avatar Stefan Leichter Committed by Alexandre Julliard

setupapi: Implement SetupGetInfFileListA.

parent 714283c9
......@@ -1463,6 +1463,40 @@ BOOL WINAPI SetupInstallServicesFromInfSectionA( HINF Inf, PCSTR SectionName, DW
/***********************************************************************
* SetupGetInfFileListA (SETUPAPI.@)
*/
BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer,
DWORD insize, PDWORD outsize)
{
UNICODE_STRING dirW;
PWSTR bufferW = NULL;
BOOL ret = FALSE;
DWORD outsizeA, outsizeW;
if ( dir )
RtlCreateUnicodeStringFromAsciiz( &dirW, dir );
else
dirW.Buffer = NULL;
if ( buffer )
bufferW = HeapAlloc( GetProcessHeap(), 0, insize * sizeof( WCHAR ));
ret = SetupGetInfFileListW( dirW.Buffer, style, bufferW, insize, &outsizeW);
if ( ret )
{
outsizeA = WideCharToMultiByte( CP_ACP, 0, bufferW, outsizeW,
buffer, insize, NULL, NULL);
if ( outsize ) *outsize = outsizeA;
}
HeapFree( GetProcessHeap(), 0, bufferW );
RtlFreeUnicodeString( &dirW );
return ret;
}
/***********************************************************************
* SetupGetInfFileListW (SETUPAPI.@)
*/
BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer,
......
......@@ -412,7 +412,7 @@
@ stdcall SetupGetFileCompressionInfoW(wstr ptr ptr ptr ptr)
@ stdcall SetupGetFileQueueCount(long long ptr)
@ stdcall SetupGetFileQueueFlags(long ptr)
@ stub SetupGetInfFileListA
@ stdcall SetupGetInfFileListA(str long ptr long ptr)
@ stdcall SetupGetInfFileListW(wstr long ptr long ptr)
@ stdcall SetupGetInfInformationA(ptr long ptr long ptr)
@ stdcall SetupGetInfInformationW(ptr long ptr long ptr)
......
......@@ -53,6 +53,7 @@ static char CURR_DIR[MAX_PATH];
static void (WINAPI *pInstallHinfSectionA)(HWND, HINSTANCE, LPCSTR, INT);
static void (WINAPI *pInstallHinfSectionW)(HWND, HINSTANCE, LPCWSTR, INT);
static BOOL (WINAPI *pSetupGetInfFileListA)(PCSTR, DWORD, PSTR, DWORD, PDWORD);
static BOOL (WINAPI *pSetupGetInfFileListW)(PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
/*
......@@ -468,6 +469,65 @@ cleanup:
DeleteFile(inffile);
}
static void test_inffilelistA(void)
{
static const char inffile2[] = "test2.inf";
static const char *inf =
"[Version]\n"
"Signature=\"$Chicago$\"";
char buffer[MAX_PATH] = { 0 };
char dir[MAX_PATH], *p;
DWORD expected, outsize;
BOOL ret;
if(!pSetupGetInfFileListA)
{
win_skip("SetupGetInfFileListA not present\n");
return;
}
/* create a private directory, the temp directory may contain some
* inf files left over from old installations
*/
if (!GetTempFileNameA(CURR_DIR, "inftest", 1, dir))
{
win_skip("GetTempFileNameA failed with error %d\n", GetLastError());
return;
}
if (!CreateDirectoryA(dir, NULL ))
{
win_skip("CreateDirectoryA(%s) failed with error %d\n", dir, GetLastError());
return;
}
if (!SetCurrentDirectoryA(dir))
{
win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError());
RemoveDirectoryA(dir);
return;
}
create_inf_file(inffile, inf);
create_inf_file(inffile2, inf);
/* mixed style
*/
expected = 3 + strlen(inffile) + strlen(inffile2);
ret = pSetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer,
MAX_PATH, &outsize);
ok(ret, "expected SetupGetInfFileListA to succeed!\n");
ok(expected == outsize, "expected required buffersize to be %d, got %d\n",
expected, outsize);
for(p = buffer; lstrlenA(p) && (outsize > (p - buffer)); p+=lstrlenA(p) + 1)
ok(!lstrcmpA(p,inffile2) || !lstrcmpA(p,inffile),
"unexpected filename %s\n",p);
DeleteFile(inffile);
DeleteFile(inffile2);
SetCurrentDirectoryA(CURR_DIR);
RemoveDirectoryA(dir);
}
static void test_inffilelist(void)
{
static const char inffile2[] = "test2.inf";
......@@ -656,6 +716,7 @@ START_TEST(install)
pInstallHinfSectionA = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionA");
pInstallHinfSectionW = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionW");
pSetupGetInfFileListA = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListA");
pSetupGetInfFileListW = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListW");
if (pInstallHinfSectionA)
......@@ -695,6 +756,7 @@ START_TEST(install)
}
test_inffilelist();
test_inffilelistA();
SetCurrentDirectory(prev_path);
}
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