Merge from amd64-branch:
[reactos.git] / rostests / winetests / advpack / files.c
1 /*
2 * Unit tests for advpack.dll file functions
3 *
4 * Copyright (C) 2006 James Hawkins
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20
21 #include <stdio.h>
22 #include <windows.h>
23 #include <advpub.h>
24 #include <fci.h>
25 #include "wine/test.h"
26
27 /* make the max size large so there is only one cab file */
28 #define MEDIA_SIZE 999999999
29 #define FOLDER_THRESHOLD 900000
30
31 /* function pointers */
32 HMODULE hAdvPack;
33 static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
34 static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
35 static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
36
37 CHAR CURR_DIR[MAX_PATH];
38
39 static void init_function_pointers(void)
40 {
41 hAdvPack = LoadLibraryA("advpack.dll");
42
43 if (hAdvPack)
44 {
45 pAddDelBackupEntry = (void *)GetProcAddress(hAdvPack, "AddDelBackupEntry");
46 pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
47 pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
48 }
49 }
50
51 /* creates a file with the specified name for tests */
52 static void createTestFile(const CHAR *name)
53 {
54 HANDLE file;
55 DWORD written;
56
57 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
58 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
59 WriteFile(file, name, strlen(name), &written, NULL);
60 WriteFile(file, "\n", strlen("\n"), &written, NULL);
61 CloseHandle(file);
62 }
63
64 static void create_test_files(void)
65 {
66 createTestFile("a.txt");
67 createTestFile("b.txt");
68 CreateDirectoryA("testdir", NULL);
69 createTestFile("testdir\\c.txt");
70 createTestFile("testdir\\d.txt");
71 CreateDirectoryA("dest", NULL);
72 }
73
74 static void delete_test_files(void)
75 {
76 DeleteFileA("a.txt");
77 DeleteFileA("b.txt");
78 DeleteFileA("testdir\\c.txt");
79 DeleteFileA("testdir\\d.txt");
80 RemoveDirectoryA("testdir");
81 RemoveDirectoryA("dest");
82
83 DeleteFileA("extract.cab");
84 }
85
86 static BOOL check_ini_file_attr(LPSTR filename)
87 {
88 BOOL ret;
89 DWORD expected = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY;
90 DWORD attr = GetFileAttributesA(filename);
91
92 ret = (attr & expected) && (attr != INVALID_FILE_ATTRIBUTES);
93 SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL);
94
95 return ret;
96 }
97
98 static void test_AddDelBackupEntry(void)
99 {
100 BOOL ret;
101 HRESULT res;
102 CHAR path[MAX_PATH];
103 CHAR windir[MAX_PATH];
104
105 lstrcpyA(path, CURR_DIR);
106 lstrcatA(path, "\\backup\\basename.INI");
107
108 /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
109
110 /* try a NULL file list */
111 res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
112 ok(res == S_OK, "Expected S_OK, got %d\n", res);
113 ok(!DeleteFileA(path), "Expected path to not exist\n");
114
115 lstrcpyA(path, CURR_DIR);
116 lstrcatA(path, "\\backup\\.INI");
117
118 /* try an empty base name */
119 res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
120 ok(res == S_OK, "Expected S_OK, got %d\n", res);
121 ok(!DeleteFileA(path), "Expected path to not exist\n");
122
123 lstrcpyA(path, CURR_DIR);
124 lstrcatA(path, "\\basename.INI");
125
126 /* try an invalid flag */
127 res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
128 ok(res == S_OK, "Expected S_OK, got %d\n", res);
129 ok(!DeleteFileA(path), "Expected path to not exist\n");
130
131 lstrcpyA(path, "c:\\basename.INI");
132
133 /* create the INF file */
134 res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
135 ok(res == S_OK, "Expected S_OK, got %d\n", res);
136 if (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES)
137 {
138 ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
139 ok(DeleteFileA(path), "Expected path to exist\n");
140 }
141 else
142 win_skip("Test file could not be created\n");
143
144 lstrcpyA(path, CURR_DIR);
145 lstrcatA(path, "\\backup\\basename.INI");
146
147 /* try to create the INI file in a nonexistent directory */
148 RemoveDirectoryA("backup");
149 res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
150 ok(res == S_OK, "Expected S_OK, got %d\n", res);
151 ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
152 ok(!DeleteFileA(path), "Expected path to not exist\n");
153
154 /* try an existent, relative backup directory */
155 CreateDirectoryA("backup", NULL);
156 res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
157 ok(res == S_OK, "Expected S_OK, got %d\n", res);
158 ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
159 ok(DeleteFileA(path), "Expected path to exist\n");
160 RemoveDirectoryA("backup");
161
162 GetWindowsDirectoryA(windir, sizeof(windir));
163 sprintf(path, "%s\\basename.INI", windir);
164
165 /* try a NULL backup dir, INI is created in the windows directory */
166 res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
167 ok(res == S_OK, "Expected S_OK, got %d\n", res);
168
169 /* remove the entries with AADBE_DEL_ENTRY */
170 SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
171 res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
172 SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
173 ok(res == S_OK, "Expected S_OK, got %d\n", res);
174 ret = DeleteFileA(path);
175 ok(ret == TRUE ||
176 broken(ret == FALSE), /* win98 */
177 "Expected path to exist\n");
178 }
179
180 /* the FCI callbacks */
181
182 static void * CDECL mem_alloc(ULONG cb)
183 {
184 return HeapAlloc(GetProcessHeap(), 0, cb);
185 }
186
187 static void CDECL mem_free(void *memory)
188 {
189 HeapFree(GetProcessHeap(), 0, memory);
190 }
191
192 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
193 {
194 return TRUE;
195 }
196
197 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
198 {
199 return 0;
200 }
201
202 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
203 BOOL fContinuation, void *pv)
204 {
205 return 0;
206 }
207
208 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
209 {
210 HANDLE handle;
211 DWORD dwAccess = 0;
212 DWORD dwShareMode = 0;
213 DWORD dwCreateDisposition = OPEN_EXISTING;
214
215 dwAccess = GENERIC_READ | GENERIC_WRITE;
216 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
217 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
218
219 if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
220 dwCreateDisposition = OPEN_EXISTING;
221 else
222 dwCreateDisposition = CREATE_NEW;
223
224 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
225 dwCreateDisposition, 0, NULL);
226
227 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
228
229 return (INT_PTR)handle;
230 }
231
232 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
233 {
234 HANDLE handle = (HANDLE)hf;
235 DWORD dwRead;
236 BOOL res;
237
238 res = ReadFile(handle, memory, cb, &dwRead, NULL);
239 ok(res, "Failed to ReadFile\n");
240
241 return dwRead;
242 }
243
244 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
245 {
246 HANDLE handle = (HANDLE)hf;
247 DWORD dwWritten;
248 BOOL res;
249
250 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
251 ok(res, "Failed to WriteFile\n");
252
253 return dwWritten;
254 }
255
256 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
257 {
258 HANDLE handle = (HANDLE)hf;
259 ok(CloseHandle(handle), "Failed to CloseHandle\n");
260
261 return 0;
262 }
263
264 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
265 {
266 HANDLE handle = (HANDLE)hf;
267 DWORD ret;
268
269 ret = SetFilePointer(handle, dist, NULL, seektype);
270 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
271
272 return ret;
273 }
274
275 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
276 {
277 BOOL ret = DeleteFileA(pszFile);
278 ok(ret, "Failed to DeleteFile %s\n", pszFile);
279
280 return 0;
281 }
282
283 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
284 {
285 LPSTR tempname;
286
287 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
288 GetTempFileNameA(".", "xx", 0, tempname);
289
290 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
291 {
292 lstrcpyA(pszTempName, tempname);
293 HeapFree(GetProcessHeap(), 0, tempname);
294 return TRUE;
295 }
296
297 HeapFree(GetProcessHeap(), 0, tempname);
298
299 return FALSE;
300 }
301
302 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
303 USHORT *pattribs, int *err, void *pv)
304 {
305 BY_HANDLE_FILE_INFORMATION finfo;
306 FILETIME filetime;
307 HANDLE handle;
308 DWORD attrs;
309 BOOL res;
310
311 handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
312 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
313
314 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
315
316 res = GetFileInformationByHandle(handle, &finfo);
317 ok(res, "Expected GetFileInformationByHandle to succeed\n");
318
319 FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
320 FileTimeToDosDateTime(&filetime, pdate, ptime);
321
322 attrs = GetFileAttributes(pszName);
323 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
324
325 return (INT_PTR)handle;
326 }
327
328 static void add_file(HFCI hfci, char *file)
329 {
330 char path[MAX_PATH];
331 BOOL res;
332
333 lstrcpyA(path, CURR_DIR);
334 lstrcatA(path, "\\");
335 lstrcatA(path, file);
336
337 res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
338 get_open_info, tcompTYPE_MSZIP);
339 ok(res, "Expected FCIAddFile to succeed\n");
340 }
341
342 static void set_cab_parameters(PCCAB pCabParams)
343 {
344 ZeroMemory(pCabParams, sizeof(CCAB));
345
346 pCabParams->cb = MEDIA_SIZE;
347 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
348 pCabParams->setID = 0xbeef;
349 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
350 lstrcatA(pCabParams->szCabPath, "\\");
351 lstrcpyA(pCabParams->szCab, "extract.cab");
352 }
353
354 static void create_cab_file(void)
355 {
356 CCAB cabParams;
357 HFCI hfci;
358 ERF erf;
359 static CHAR a_txt[] = "a.txt",
360 b_txt[] = "b.txt",
361 testdir_c_txt[] = "testdir\\c.txt",
362 testdir_d_txt[] = "testdir\\d.txt";
363 BOOL res;
364
365 set_cab_parameters(&cabParams);
366
367 hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
368 fci_read, fci_write, fci_close, fci_seek, fci_delete,
369 get_temp_file, &cabParams, NULL);
370
371 ok(hfci != NULL, "Failed to create an FCI context\n");
372
373 add_file(hfci, a_txt);
374 add_file(hfci, b_txt);
375 add_file(hfci, testdir_c_txt);
376 add_file(hfci, testdir_d_txt);
377
378 res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
379 ok(res, "Failed to flush the cabinet\n");
380
381 res = FCIDestroy(hfci);
382 ok(res, "Failed to destroy the cabinet\n");
383 }
384
385 static void test_ExtractFiles(void)
386 {
387 HRESULT hr;
388 char destFolder[MAX_PATH];
389
390 lstrcpyA(destFolder, CURR_DIR);
391 lstrcatA(destFolder, "\\");
392 lstrcatA(destFolder, "dest");
393
394 /* try NULL cab file */
395 hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
396 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
397 ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
398
399 /* try NULL destination */
400 hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
401 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
402 ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
403
404 /* extract all files in the cab to nonexistent destination directory */
405 hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
406 ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) ||
407 hr == E_FAIL, /* win95 */
408 "Expected %08x or %08x, got %08x\n", E_FAIL,
409 HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
410 ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
411 ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
412 ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
413 ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
414
415 /* extract all files in the cab to the destination directory */
416 CreateDirectoryA("dest", NULL);
417 hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
418 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
419 ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
420 ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
421 ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
422 ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
423 ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
424
425 /* extract all files to a relative destination directory */
426 hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
427 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
428 ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
429 ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
430 ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
431 ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
432 ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
433
434 /* only extract two of the files from the cab */
435 hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
436 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
437 ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
438 ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
439 ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
440 ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
441 ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
442
443 /* use valid chars before and after file list */
444 hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt \t:", NULL, 0);
445 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
446 ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
447 ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
448 ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
449 ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
450 ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
451
452 /* use invalid chars before and after file list */
453 hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt a_:", NULL, 0);
454 ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
455 ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
456 ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
457 ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
458
459 /* try an empty file list */
460 hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
461 ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
462 ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
463 ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
464
465 /* try a nonexistent file in the file list */
466 hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
467 ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
468 ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
469 ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
470 ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
471 }
472
473 static void test_AdvInstallFile(void)
474 {
475 HRESULT hr;
476 HMODULE hmod;
477 char CURR_DIR[MAX_PATH];
478 char destFolder[MAX_PATH];
479
480 hmod = LoadLibrary("setupapi.dll");
481 if (!hmod)
482 {
483 skip("setupapi.dll not present\n");
484 return;
485 }
486
487 FreeLibrary(hmod);
488
489 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
490
491 lstrcpyA(destFolder, CURR_DIR);
492 lstrcatA(destFolder, "\\");
493 lstrcatA(destFolder, "dest");
494
495 createTestFile("source.txt");
496
497 /* try invalid source directory */
498 hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
499 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
500 ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
501
502 /* try invalid source file */
503 hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
504 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
505 ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
506
507 /* try invalid destination directory */
508 hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
509 ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
510 ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
511
512 /* try copying to nonexistent destination directory */
513 hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
514 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
515 ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
516
517 /* native windows screws up if the source file doesn't exist */
518
519 /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
520 createTestFile("dest\\destination.txt");
521 hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
522 "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
523 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
524 ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
525 ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
526
527 DeleteFileA("source.txt");
528 }
529
530 START_TEST(files)
531 {
532 DWORD len;
533 char temp_path[MAX_PATH], prev_path[MAX_PATH];
534
535 init_function_pointers();
536
537 GetCurrentDirectoryA(MAX_PATH, prev_path);
538 GetTempPath(MAX_PATH, temp_path);
539 SetCurrentDirectoryA(temp_path);
540
541 lstrcpyA(CURR_DIR, temp_path);
542 len = lstrlenA(CURR_DIR);
543
544 if(len && (CURR_DIR[len - 1] == '\\'))
545 CURR_DIR[len - 1] = 0;
546
547 create_test_files();
548 create_cab_file();
549
550 test_AddDelBackupEntry();
551 test_ExtractFiles();
552 test_AdvInstallFile();
553
554 delete_test_files();
555
556 FreeLibrary(hAdvPack);
557 SetCurrentDirectoryA(prev_path);
558 }