advpack: Added ExtractFilesW implementation.

This commit is contained in:
Jacek Caban 2012-10-31 11:28:28 +01:00 committed by Alexandre Julliard
parent a49da3ca5d
commit 57b83719b7
3 changed files with 72 additions and 2 deletions

View File

@ -27,4 +27,27 @@ void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir) DECL
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE) DECLSPEC_HIDDEN;
static inline void *heap_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline BOOL heap_free(void *mem)
{
return HeapFree(GetProcessHeap(), 0, mem);
}
static inline char *heap_strdupWtoA(const WCHAR *str)
{
char *ret = NULL;
if(str) {
size_t size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = heap_alloc(size);
WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
}
return ret;
}
#endif /* __ADVPACK_PRIVATE_H */

View File

@ -779,11 +779,39 @@ done:
HRESULT WINAPI ExtractFilesW(LPCWSTR CabName, LPCWSTR ExpandDir, DWORD Flags,
LPCWSTR FileList, LPVOID LReserved, DWORD Reserved)
{
char *cab_name = NULL, *expand_dir = NULL, *file_list = NULL;
HRESULT hres = S_OK;
FIXME("(%s, %s, %d, %s, %p, %d) stub!\n", debugstr_w(CabName), debugstr_w(ExpandDir),
TRACE("(%s, %s, %d, %s, %p, %d)\n", debugstr_w(CabName), debugstr_w(ExpandDir),
Flags, debugstr_w(FileList), LReserved, Reserved);
return E_FAIL;
if(CabName) {
cab_name = heap_strdupWtoA(CabName);
if(!cab_name)
return E_OUTOFMEMORY;
}
if(ExpandDir) {
expand_dir = heap_strdupWtoA(ExpandDir);
if(!expand_dir)
hres = E_OUTOFMEMORY;
}
if(SUCCEEDED(hres) && FileList) {
file_list = heap_strdupWtoA(FileList);
if(!file_list)
hres = E_OUTOFMEMORY;
}
/* cabinet.dll, which does the real job of extracting files, doesn't have UNICODE API,
so we need W->A conversion at some point anyway. */
if(SUCCEEDED(hres))
hres = ExtractFilesA(cab_name, expand_dir, Flags, file_list, LReserved, Reserved);
heap_free(cab_name);
heap_free(expand_dir);
heap_free(file_list);
return hres;
}
/***********************************************************************

View File

@ -32,6 +32,7 @@
static HMODULE hAdvPack;
static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
static HRESULT (WINAPI *pExtractFilesW)(const WCHAR*,const WCHAR*,DWORD,const WCHAR*,void*,DWORD);
static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
static CHAR CURR_DIR[MAX_PATH];
@ -44,6 +45,7 @@ static void init_function_pointers(void)
{
pAddDelBackupEntry = (void *)GetProcAddress(hAdvPack, "AddDelBackupEntry");
pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
pExtractFilesW = (void *)GetProcAddress(hAdvPack, "ExtractFilesW");
pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
}
}
@ -468,6 +470,23 @@ static void test_ExtractFiles(void)
ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
if(pExtractFilesW) {
static const WCHAR extract_cabW[] = {'e','x','t','r','a','c','t','.','c','a','b',0};
static const WCHAR destW[] = {'d','e','s','t',0};
static const WCHAR file_listW[] =
{'a','.','t','x','t',':','t','e','s','t','d','i','r','\\','c','.','t','x','t',0};
hr = pExtractFilesW(extract_cabW, destW, 0, file_listW, NULL, 0);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
}else {
win_skip("ExtractFilesW not available\n");
}
}
static void test_AdvInstallFile(void)