comctl32: Update Polish translation.
[wine] / dlls / advpack / tests / 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     int len;
67
68     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
69     len = lstrlenA(CURR_DIR);
70
71     if(len && (CURR_DIR[len-1] == '\\'))
72         CURR_DIR[len-1] = 0;
73
74     createTestFile("a.txt");
75     createTestFile("b.txt");
76     CreateDirectoryA("testdir", NULL);
77     createTestFile("testdir\\c.txt");
78     createTestFile("testdir\\d.txt");
79     CreateDirectoryA("dest", NULL);
80 }
81
82 static void delete_test_files(void)
83 {
84     DeleteFileA("a.txt");
85     DeleteFileA("b.txt");
86     DeleteFileA("testdir\\c.txt");
87     DeleteFileA("testdir\\d.txt");
88     RemoveDirectoryA("testdir");
89     RemoveDirectoryA("dest");
90
91     DeleteFileA("extract.cab");
92 }
93
94 static BOOL check_ini_file_attr(LPSTR filename)
95 {
96     BOOL ret;
97     DWORD expected = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY;
98     DWORD attr = GetFileAttributesA(filename);
99
100     ret = (attr & expected) && (attr != INVALID_FILE_ATTRIBUTES);
101     SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL);
102
103     return ret;
104 }
105
106 #define FIELD_LEN   16
107
108 static BOOL check_ini_contents(LPSTR filename, BOOL add)
109 {
110     CHAR field[FIELD_LEN];
111     BOOL ret = TRUE, match;
112
113     GetPrivateProfileStringA("backup", "one", NULL, field, FIELD_LEN, filename);
114     match = !lstrcmpA(field, "-1,0,0,0,0,0,-1");
115     if ((add && !match) || (!add && match))
116         ret = FALSE;
117
118     GetPrivateProfileStringA("backup", "two", NULL, field, FIELD_LEN, filename);
119     if (lstrcmpA(field, "-1,0,0,0,0,0,-1"))
120         ret = FALSE;
121
122     GetPrivateProfileStringA("backup", "three", NULL, field, FIELD_LEN, filename);
123     match = !lstrcmpA(field, "-1,0,0,0,0,0,-1");
124     if ((add && !match) || (!add && match))
125         ret = FALSE;
126
127     return ret;
128 }
129
130 static void test_AddDelBackupEntry(void)
131 {
132     HRESULT res;
133     CHAR path[MAX_PATH];
134
135     lstrcpyA(path, CURR_DIR);
136     lstrcatA(path, "\\backup\\basename.INI");
137
138     /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
139
140     /* try a NULL file list */
141     res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
142     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
143     ok(!DeleteFileA(path), "Expected path to not exist\n");
144
145     lstrcpyA(path, CURR_DIR);
146     lstrcatA(path, "\\backup\\.INI");
147
148     /* try an empty base name */
149     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
150     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
151     ok(!DeleteFileA(path), "Expected path to not exist\n");
152
153     lstrcpyA(path, CURR_DIR);
154     lstrcatA(path, "\\basename.INI");
155
156     /* try an invalid flag */
157     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
158     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
159     ok(!DeleteFileA(path), "Expected path to not exist\n");
160
161     lstrcpyA(path, "c:\\basename.INI");
162
163     /* create the INF file */
164     res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
165     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
166     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
167     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
168     ok(DeleteFileA(path), "Expected path to exist\n");
169
170     lstrcpyA(path, CURR_DIR);
171     lstrcatA(path, "\\backup\\basename.INI");
172
173     /* try to create the INI file in a nonexistent directory */
174     RemoveDirectoryA("backup");
175     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
176     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
177     ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
178     ok(!check_ini_contents(path, TRUE), "Expected ini contents to not match\n");
179     ok(!DeleteFileA(path), "Expected path to not exist\n");
180
181     /* try an existent, relative backup directory */
182     CreateDirectoryA("backup", NULL);
183     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
184     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
185     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
186     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
187     ok(DeleteFileA(path), "Expected path to exist\n");
188     RemoveDirectoryA("backup");
189
190     lstrcpyA(path, "c:\\windows\\basename.INI");
191
192     /* try a NULL backup dir, INI is created in c:\windows */
193     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
194     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
195     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
196
197     /* remove the entries with AADBE_DEL_ENTRY */
198     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
199     res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
200     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
201     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
202     ok(check_ini_contents(path, FALSE), "Expected ini contents to match\n");
203     ok(DeleteFileA(path), "Expected path to exist\n");
204 }
205
206 /* the FCI callbacks */
207
208 static void *mem_alloc(ULONG cb)
209 {
210     return HeapAlloc(GetProcessHeap(), 0, cb);
211 }
212
213 static void mem_free(void *memory)
214 {
215     HeapFree(GetProcessHeap(), 0, memory);
216 }
217
218 static BOOL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
219 {
220     return TRUE;
221 }
222
223 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
224 {
225     return 0;
226 }
227
228 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
229                        BOOL fContinuation, void *pv)
230 {
231     return 0;
232 }
233
234 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
235 {
236     HANDLE handle;
237     DWORD dwAccess = 0;
238     DWORD dwShareMode = 0;
239     DWORD dwCreateDisposition = OPEN_EXISTING;
240     
241     dwAccess = GENERIC_READ | GENERIC_WRITE;
242     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
243
244     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
245         dwCreateDisposition = OPEN_EXISTING;
246     else
247         dwCreateDisposition = CREATE_NEW;
248
249     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
250                          dwCreateDisposition, 0, NULL);
251
252     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
253
254     return (INT_PTR)handle;
255 }
256
257 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
258 {
259     HANDLE handle = (HANDLE)hf;
260     DWORD dwRead;
261     BOOL res;
262     
263     res = ReadFile(handle, memory, cb, &dwRead, NULL);
264     ok(res, "Failed to ReadFile\n");
265
266     return dwRead;
267 }
268
269 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
270 {
271     HANDLE handle = (HANDLE)hf;
272     DWORD dwWritten;
273     BOOL res;
274
275     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
276     ok(res, "Failed to WriteFile\n");
277
278     return dwWritten;
279 }
280
281 static int fci_close(INT_PTR hf, int *err, void *pv)
282 {
283     HANDLE handle = (HANDLE)hf;
284     ok(CloseHandle(handle), "Failed to CloseHandle\n");
285
286     return 0;
287 }
288
289 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
290 {
291     HANDLE handle = (HANDLE)hf;
292     DWORD ret;
293     
294     ret = SetFilePointer(handle, dist, NULL, seektype);
295     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
296
297     return ret;
298 }
299
300 static int fci_delete(char *pszFile, int *err, void *pv)
301 {
302     BOOL ret = DeleteFileA(pszFile);
303     ok(ret, "Failed to DeleteFile %s\n", pszFile);
304
305     return 0;
306 }
307
308 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
309 {
310     LPSTR tempname;
311
312     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
313     GetTempFileNameA(".", "xx", 0, tempname);
314
315     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
316     {
317         lstrcpyA(pszTempName, tempname);
318         HeapFree(GetProcessHeap(), 0, tempname);
319         return TRUE;
320     }
321
322     HeapFree(GetProcessHeap(), 0, tempname);
323
324     return FALSE;
325 }
326
327 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
328                              USHORT *pattribs, int *err, void *pv)
329 {
330     BY_HANDLE_FILE_INFORMATION finfo;
331     FILETIME filetime;
332     HANDLE handle;
333     DWORD attrs;
334     BOOL res;
335
336     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
337                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
338
339     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
340
341     res = GetFileInformationByHandle(handle, &finfo);
342     ok(res, "Expected GetFileInformationByHandle to succeed\n");
343    
344     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
345     FileTimeToDosDateTime(&filetime, pdate, ptime);
346
347     attrs = GetFileAttributes(pszName);
348     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
349
350     return (INT_PTR)handle;
351 }
352
353 static void add_file(HFCI hfci, char *file)
354 {
355     char path[MAX_PATH];
356     BOOL res;
357
358     lstrcpyA(path, CURR_DIR);
359     lstrcatA(path, "\\");
360     lstrcatA(path, file);
361
362     res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
363                      get_open_info, tcompTYPE_MSZIP);
364     ok(res, "Expected FCIAddFile to succeed\n");
365 }
366
367 static void set_cab_parameters(PCCAB pCabParams)
368 {
369     ZeroMemory(pCabParams, sizeof(CCAB));
370
371     pCabParams->cb = MEDIA_SIZE;
372     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
373     pCabParams->setID = 0xbeef;
374     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
375     lstrcatA(pCabParams->szCabPath, "\\");
376     lstrcpyA(pCabParams->szCab, "extract.cab");
377 }
378
379 static void create_cab_file(void)
380 {
381     CCAB cabParams;
382     HFCI hfci;
383     ERF erf;
384     static CHAR a_txt[] = "a.txt",
385                 b_txt[] = "b.txt",
386                 testdir_c_txt[] = "testdir\\c.txt",
387                 testdir_d_txt[] = "testdir\\d.txt";
388     BOOL res;
389
390     set_cab_parameters(&cabParams);
391
392     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
393                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
394                       get_temp_file, &cabParams, NULL);
395
396     ok(hfci != NULL, "Failed to create an FCI context\n");
397
398     add_file(hfci, a_txt);
399     add_file(hfci, b_txt);
400     add_file(hfci, testdir_c_txt);
401     add_file(hfci, testdir_d_txt);
402
403     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
404     ok(res, "Failed to flush the cabinet\n");
405
406     res = FCIDestroy(hfci);
407     ok(res, "Failed to destroy the cabinet\n");
408 }
409
410 static void test_ExtractFiles(void)
411 {
412     HRESULT hr;
413     char destFolder[MAX_PATH];
414
415     lstrcpyA(destFolder, CURR_DIR);
416     lstrcatA(destFolder, "\\");
417     lstrcatA(destFolder, "dest");
418
419     /* try NULL cab file */
420     hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
421     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
422     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
423     
424     /* try NULL destination */
425     hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
426     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
427     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
428
429     /* extract all files in the cab to nonexistent destination directory */
430     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
431     ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND),
432        "Expected %ld, got %ld\n", HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
433     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
434     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
435     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
436     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
437
438     /* extract all files in the cab to the destination directory */
439     CreateDirectoryA("dest", NULL);
440     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
441     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
442     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
443     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
444     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
445     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
446     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
447
448     /* extract all files to a relative destination directory */
449     hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
450     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
451     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
452     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
453     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
454     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
455     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
456
457     /* only extract two of the files from the cab */
458     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
459     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
460     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
461     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
462     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
463     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
464     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
465
466     /* use valid chars before and after file list */
467     hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt  \t:", NULL, 0);
468     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
469     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
470     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
471     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
472     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
473     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
474
475     /* use invalid chars before and after file list */
476     hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt  a_:", NULL, 0);
477     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
478     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
479     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
480     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
481
482     /* try an empty file list */
483     hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
484     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
485     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
486     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
487
488     /* try a nonexistent file in the file list */
489     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
490     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
491     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
492     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
493     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
494 }
495
496 static void test_AdvInstallFile(void)
497 {
498     HRESULT hr;
499     char CURR_DIR[MAX_PATH];
500     char destFolder[MAX_PATH];
501
502     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
503
504     lstrcpyA(destFolder, CURR_DIR);
505     lstrcatA(destFolder, "\\");
506     lstrcatA(destFolder, "dest");
507
508     createTestFile("source.txt");
509
510     /* try invalid source directory */
511     hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
512     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
513     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
514
515     /* try invalid source file */
516     hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
517     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
518     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
519
520     /* try invalid destination directory */
521     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
522     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
523     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
524
525     /* try copying to nonexistent destination directory */
526     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
527     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
528     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
529
530     /* native windows screws up if the source file doesn't exist */
531
532     /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
533     createTestFile("dest\\destination.txt");
534     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
535                          "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
536     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
537     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
538     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
539
540     DeleteFileA("source.txt");
541 }
542
543 START_TEST(files)
544 {
545     init_function_pointers();
546     create_test_files();
547     create_cab_file();
548
549     test_AddDelBackupEntry();
550     test_ExtractFiles();
551     test_AdvInstallFile();
552
553     delete_test_files();
554 }