Jacek Caban : advpack: Added ExtractFilesW implementation.
Alexandre Julliard
julliard at winehq.org
Wed Oct 31 17:17:21 CDT 2012
Module: wine
Branch: master
Commit: 57b83719b7921c5af268fdfcff633012bf95c3b0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=57b83719b7921c5af268fdfcff633012bf95c3b0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Oct 31 11:28:28 2012 +0100
advpack: Added ExtractFilesW implementation.
---
dlls/advpack/advpack_private.h | 23 +++++++++++++++++++++++
dlls/advpack/files.c | 32 ++++++++++++++++++++++++++++++--
dlls/advpack/tests/files.c | 19 +++++++++++++++++++
3 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/advpack/advpack_private.h b/dlls/advpack/advpack_private.h
index cbbbf48..a1bcfe4 100644
--- a/dlls/advpack/advpack_private.h
+++ b/dlls/advpack/advpack_private.h
@@ -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 */
diff --git a/dlls/advpack/files.c b/dlls/advpack/files.c
index f6056f2..c34f6d5 100644
--- a/dlls/advpack/files.c
+++ b/dlls/advpack/files.c
@@ -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;
}
/***********************************************************************
diff --git a/dlls/advpack/tests/files.c b/dlls/advpack/tests/files.c
index 9bb8cde..4a985be 100644
--- a/dlls/advpack/tests/files.c
+++ b/dlls/advpack/tests/files.c
@@ -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)
More information about the wine-cvs
mailing list