ReactOS  0.4.13-dev-52-g0efcfec
files.c
Go to the documentation of this file.
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 */
33 static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
34 static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
35 static HRESULT (WINAPI *pExtractFilesW)(const WCHAR*,const WCHAR*,DWORD,const WCHAR*,void*,DWORD);
36 static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
37 
39 
40 static void init_function_pointers(void)
41 {
42  hAdvPack = LoadLibraryA("advpack.dll");
43 
44  if (hAdvPack)
45  {
46  pAddDelBackupEntry = (void *)GetProcAddress(hAdvPack, "AddDelBackupEntry");
47  pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
48  pExtractFilesW = (void *)GetProcAddress(hAdvPack, "ExtractFilesW");
49  pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
50  }
51 }
52 
53 /* creates a file with the specified name for tests */
54 static void createTestFile(const CHAR *name)
55 {
56  HANDLE file;
57  DWORD written;
58 
60  ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
61  WriteFile(file, name, strlen(name), &written, NULL);
62  WriteFile(file, "\n", strlen("\n"), &written, NULL);
64 }
65 
66 static void create_test_files(void)
67 {
68  createTestFile("a.txt");
69  createTestFile("b.txt");
70  CreateDirectoryA("testdir", NULL);
71  createTestFile("testdir\\c.txt");
72  createTestFile("testdir\\d.txt");
73  CreateDirectoryA("dest", NULL);
74 }
75 
76 static void delete_test_files(void)
77 {
78  DeleteFileA("a.txt");
79  DeleteFileA("b.txt");
80  DeleteFileA("testdir\\c.txt");
81  DeleteFileA("testdir\\d.txt");
82  RemoveDirectoryA("testdir");
83  RemoveDirectoryA("dest");
84 
85  DeleteFileA("extract.cab");
86 }
87 
89 {
90  BOOL ret;
93 
96 
97  return ret;
98 }
99 
100 static void test_AddDelBackupEntry(void)
101 {
102  BOOL ret;
103  HRESULT res;
104  CHAR path[MAX_PATH];
105  CHAR windir[MAX_PATH];
106 
108  lstrcatA(path, "\\backup\\basename.INI");
109 
110  /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
111 
112  /* try a NULL file list */
113  res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
114  ok(res == S_OK, "Expected S_OK, got %d\n", res);
115  ok(!DeleteFileA(path), "Expected path to not exist\n");
116 
118  lstrcatA(path, "\\backup\\.INI");
119 
120  /* try an empty base name */
121  res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
122  ok(res == S_OK, "Expected S_OK, got %d\n", res);
123  ok(!DeleteFileA(path), "Expected path to not exist\n");
124 
126  lstrcatA(path, "\\basename.INI");
127 
128  /* try an invalid flag */
129  res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
130  ok(res == S_OK, "Expected S_OK, got %d\n", res);
131  ok(!DeleteFileA(path), "Expected path to not exist\n");
132 
133  lstrcpyA(path, "c:\\basename.INI");
134 
135  /* create the INF file */
136  res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
137  ok(res == S_OK, "Expected S_OK, got %d\n", res);
139  {
140  ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
141  ok(DeleteFileA(path), "Expected path to exist\n");
142  }
143  else
144  win_skip("Test file could not be created\n");
145 
147  lstrcatA(path, "\\backup\\basename.INI");
148 
149  /* try to create the INI file in a nonexistent directory */
150  RemoveDirectoryA("backup");
151  res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
152  ok(res == S_OK, "Expected S_OK, got %d\n", res);
153  ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
154  ok(!DeleteFileA(path), "Expected path to not exist\n");
155 
156  /* try an existent, relative backup directory */
157  CreateDirectoryA("backup", NULL);
158  res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
159  ok(res == S_OK, "Expected S_OK, got %d\n", res);
160  ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
161  ok(DeleteFileA(path), "Expected path to exist\n");
162  RemoveDirectoryA("backup");
163 
164  GetWindowsDirectoryA(windir, sizeof(windir));
165  sprintf(path, "%s\\basename.INI", windir);
166 
167  /* try a NULL backup dir, INI is created in the windows directory */
168  res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
169  ok(res == S_OK, "Expected S_OK, got %d\n", res);
170 
171  /* remove the entries with AADBE_DEL_ENTRY */
173  res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
175  ok(res == S_OK, "Expected S_OK, got %d\n", res);
176  ret = DeleteFileA(path);
177  ok(ret == TRUE ||
178  broken(ret == FALSE), /* win98 */
179  "Expected path to exist\n");
180 }
181 
182 /* the FCI callbacks */
183 
184 static void * CDECL mem_alloc(ULONG cb)
185 {
186  return HeapAlloc(GetProcessHeap(), 0, cb);
187 }
188 
189 static void CDECL mem_free(void *memory)
190 {
192 }
193 
194 static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
195 {
196  return TRUE;
197 }
198 
199 static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
200 {
201  return 0;
202 }
203 
204 static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile,
205  BOOL fContinuation, void *pv)
206 {
207  return 0;
208 }
209 
210 static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
211 {
212  HANDLE handle;
213  DWORD dwAccess = 0;
214  DWORD dwShareMode = 0;
215  DWORD dwCreateDisposition = OPEN_EXISTING;
216 
217  dwAccess = GENERIC_READ | GENERIC_WRITE;
218  /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
219  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
220 
222  dwCreateDisposition = OPEN_EXISTING;
223  else
224  dwCreateDisposition = CREATE_NEW;
225 
226  handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
227  dwCreateDisposition, 0, NULL);
228 
229  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
230 
231  return (INT_PTR)handle;
232 }
233 
234 static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
235 {
236  HANDLE handle = (HANDLE)hf;
237  DWORD dwRead;
238  BOOL res;
239 
240  res = ReadFile(handle, memory, cb, &dwRead, NULL);
241  ok(res, "Failed to ReadFile\n");
242 
243  return dwRead;
244 }
245 
246 static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
247 {
248  HANDLE handle = (HANDLE)hf;
249  DWORD dwWritten;
250  BOOL res;
251 
252  res = WriteFile(handle, memory, cb, &dwWritten, NULL);
253  ok(res, "Failed to WriteFile\n");
254 
255  return dwWritten;
256 }
257 
258 static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
259 {
260  HANDLE handle = (HANDLE)hf;
261  ok(CloseHandle(handle), "Failed to CloseHandle\n");
262 
263  return 0;
264 }
265 
266 static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
267 {
268  HANDLE handle = (HANDLE)hf;
269  DWORD ret;
270 
271  ret = SetFilePointer(handle, dist, NULL, seektype);
272  ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
273 
274  return ret;
275 }
276 
277 static int CDECL fci_delete(char *pszFile, int *err, void *pv)
278 {
279  BOOL ret = DeleteFileA(pszFile);
280  ok(ret, "Failed to DeleteFile %s\n", pszFile);
281 
282  return 0;
283 }
284 
285 static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
286 {
287  LPSTR tempname;
288 
289  tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
290  GetTempFileNameA(".", "xx", 0, tempname);
291 
292  if (tempname && (strlen(tempname) < (unsigned)cbTempName))
293  {
294  lstrcpyA(pszTempName, tempname);
295  HeapFree(GetProcessHeap(), 0, tempname);
296  return TRUE;
297  }
298 
299  HeapFree(GetProcessHeap(), 0, tempname);
300 
301  return FALSE;
302 }
303 
304 static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
305  USHORT *pattribs, int *err, void *pv)
306 {
309  HANDLE handle;
310  DWORD attrs;
311  BOOL res;
312 
315 
316  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
317 
319  ok(res, "Expected GetFileInformationByHandle to succeed\n");
320 
322  FileTimeToDosDateTime(&filetime, pdate, ptime);
323 
324  attrs = GetFileAttributesA(pszName);
325  ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
326 
327  return (INT_PTR)handle;
328 }
329 
330 static void add_file(HFCI hfci, char *file)
331 {
332  char path[MAX_PATH];
333  BOOL res;
334 
336  lstrcatA(path, "\\");
337  lstrcatA(path, file);
338 
341  ok(res, "Expected FCIAddFile to succeed\n");
342 }
343 
344 static void set_cab_parameters(PCCAB pCabParams)
345 {
346  ZeroMemory(pCabParams, sizeof(CCAB));
347 
348  pCabParams->cb = MEDIA_SIZE;
349  pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
350  pCabParams->setID = 0xbeef;
351  lstrcpyA(pCabParams->szCabPath, CURR_DIR);
352  lstrcatA(pCabParams->szCabPath, "\\");
353  lstrcpyA(pCabParams->szCab, "extract.cab");
354 }
355 
356 static void create_cab_file(void)
357 {
358  CCAB cabParams;
359  HFCI hfci;
360  ERF erf;
361  static CHAR a_txt[] = "a.txt",
362  b_txt[] = "b.txt",
363  testdir_c_txt[] = "testdir\\c.txt",
364  testdir_d_txt[] = "testdir\\d.txt";
365  BOOL res;
366 
367  set_cab_parameters(&cabParams);
368 
371  get_temp_file, &cabParams, NULL);
372 
373  ok(hfci != NULL, "Failed to create an FCI context\n");
374 
375  add_file(hfci, a_txt);
376  add_file(hfci, b_txt);
377  add_file(hfci, testdir_c_txt);
378  add_file(hfci, testdir_d_txt);
379 
381  ok(res, "Failed to flush the cabinet\n");
382 
383  res = FCIDestroy(hfci);
384  ok(res, "Failed to destroy the cabinet\n");
385 }
386 
387 static void test_ExtractFiles(void)
388 {
389  HRESULT hr;
390  char destFolder[MAX_PATH];
391 
392  lstrcpyA(destFolder, CURR_DIR);
393  lstrcatA(destFolder, "\\");
394  lstrcatA(destFolder, "dest");
395 
396  /* try NULL cab file */
397  hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
398  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
399  ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
400 
401  /* try NULL destination */
402  hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
403  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
404  ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
405 
406  /* extract all files in the cab to nonexistent destination directory */
407  hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
409  hr == E_FAIL, /* win95 */
410  "Expected %08x or %08x, got %08x\n", E_FAIL,
412  ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
413  ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
414  ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
415  ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
416 
417  /* extract all files in the cab to the destination directory */
418  CreateDirectoryA("dest", NULL);
419  hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
420  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
421  ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
422  ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
423  ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
424  ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
425  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
426 
427  /* extract all files to a relative destination directory */
428  hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
429  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
430  ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
431  ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
432  ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
433  ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
434  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
435 
436  /* only extract two of the files from the cab */
437  hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
438  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
439  ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
440  ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
441  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
442  ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
443  ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
444 
445  /* use valid chars before and after file list */
446  hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt \t:", NULL, 0);
447  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
448  ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
449  ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
450  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
451  ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
452  ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
453 
454  /* use invalid chars before and after file list */
455  hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt a_:", NULL, 0);
456  ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
457  ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
458  ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
459  ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
460 
461  /* try an empty file list */
462  hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
463  ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
464  ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
465  ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
466 
467  /* try a nonexistent file in the file list */
468  hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
469  ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
470  ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
471  ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
472  ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
473 
474  if(pExtractFilesW) {
475  static const WCHAR extract_cabW[] = {'e','x','t','r','a','c','t','.','c','a','b',0};
476  static const WCHAR destW[] = {'d','e','s','t',0};
477  static const WCHAR file_listW[] =
478  {'a','.','t','x','t',':','t','e','s','t','d','i','r','\\','c','.','t','x','t',0};
479 
480  hr = pExtractFilesW(extract_cabW, destW, 0, file_listW, NULL, 0);
481  ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
482  ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
483  ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
484  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
485  ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
486  ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
487  }else {
488  win_skip("ExtractFilesW not available\n");
489  }
490 }
491 
492 static void test_AdvInstallFile(void)
493 {
494  HRESULT hr;
495  HMODULE hmod;
496  char destFolder[MAX_PATH];
497 
498  hmod = LoadLibraryA("setupapi.dll");
499  if (!hmod)
500  {
501  skip("setupapi.dll not present\n");
502  return;
503  }
504 
505  FreeLibrary(hmod);
506 
507  lstrcpyA(destFolder, CURR_DIR);
508  lstrcatA(destFolder, "\\");
509  lstrcatA(destFolder, "dest");
510 
511  createTestFile("source.txt");
512 
513  /* try invalid source directory */
514  hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
515  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
516  ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
517 
518  /* try invalid source file */
519  hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
520  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
521  ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
522 
523  /* try invalid destination directory */
524  hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
525  ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
526  ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
527 
528  /* try copying to nonexistent destination directory */
529  hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
530  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
531  ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
532 
533  /* native windows screws up if the source file doesn't exist */
534 
535  /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
536  createTestFile("dest\\destination.txt");
537  hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
538  "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
539  ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
540  ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
541  ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
542 
543  DeleteFileA("source.txt");
544 }
545 
547 {
548  DWORD len;
549  char temp_path[MAX_PATH], prev_path[MAX_PATH];
550 
552 
553  GetCurrentDirectoryA(MAX_PATH, prev_path);
556 
558  len = lstrlenA(CURR_DIR);
559 
560  if(len && (CURR_DIR[len - 1] == '\\'))
561  CURR_DIR[len - 1] = 0;
562 
564  create_cab_file();
565 
569 
571 
573  SetCurrentDirectoryA(prev_path);
574 }
ULONG cbFolderThresh
Definition: fci.h:146
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
static void create_test_files(void)
Definition: files.c:66
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
BOOL __cdecl FCIFlushCabinet(HFCI hfci, BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis)
Definition: fci.c:1675
HFCI __cdecl FCICreate(PERF perf, PFNFCIFILEPLACED pfnfiledest, PFNFCIALLOC pfnalloc, PFNFCIFREE pfnfree, PFNFCIOPEN pfnopen, PFNFCIREAD pfnread, PFNFCIWRITE pfnwrite, PFNFCICLOSE pfnclose, PFNFCISEEK pfnseek, PFNFCIDELETE pfndelete, PFNFCIGETTEMPFILE pfnfcigtf, PCCAB pccab, void *pv)
Definition: fci.c:998
#define MEDIA_SIZE
Definition: files.c:28
HRESULT hr
Definition: shlfolder.c:183
static LPVOID
Definition: files.c:34
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
static void test_ExtractFiles(void)
Definition: files.c:387
#define FOLDER_THRESHOLD
Definition: files.c:29
static HRESULT(WINAPI *pAddDelBackupEntry)(LPCSTR
char CHAR
Definition: xmlstorage.h:175
static void createTestFile(const CHAR *name)
Definition: files.c:54
BOOL __cdecl FCIDestroy(HFCI hfci)
Definition: fci.c:1709
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv)
Definition: files.c:204
HANDLE HWND
Definition: compat.h:13
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define ZeroMemory
Definition: winbase.h:1635
static HMODULE hAdvPack
Definition: files.c:32
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
Definition: fci.h:144
static void CDECL mem_free(void *memory)
Definition: files.c:189
int32_t INT_PTR
Definition: typedefs.h:62
char * LPSTR
Definition: xmlstorage.h:182
const char * filename
Definition: ioapi.h:135
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:211
#define E_FAIL
Definition: ddrawi.h:102
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
Definition: files.c:266
static char memory[1024 *256]
Definition: process.c:116
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
Definition: files.c:210
#define AADBE_DEL_ENTRY
Definition: advpub.h:116
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
Definition: files.c:194
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv)
Definition: files.c:304
#define FILE_SHARE_READ
Definition: compat.h:125
#define tcompTYPE_MSZIP
Definition: fci.h:65
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: files.c:246
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static void delete_test_files(void)
Definition: files.c:76
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:786
Definition: fci.h:44
#define GENERIC_WRITE
Definition: nt_native.h:90
HINSTANCE WINAPI DECLSPEC_HOTPATCH LoadLibraryA(LPCSTR lpLibFileName)
Definition: loader.c:111
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
Definition: files.c:285
char szCab[CB_MAX_CABINET_NAME]
Definition: fci.h:160
#define ok(value,...)
#define E_INVALIDARG
Definition: ddrawi.h:101
ULONG cb
Definition: fci.h:145
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
Definition: files.c:199
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
smooth NULL
Definition: ftsmooth.c:416
static void set_cab_parameters(PCCAB pCabParams)
Definition: files.c:344
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:926
static LPCSTR
Definition: files.c:541
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
Definition: files.c:258
#define OPEN_EXISTING
Definition: compat.h:426
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static void create_cab_file(void)
Definition: files.c:356
#define FreeLibrary(x)
Definition: compat.h:405
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:608
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
double __cdecl erf(double)
static void init_function_pointers(void)
Definition: files.c:40
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
const char file[]
Definition: icontest.c:11
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
PVOID HANDLE
Definition: typedefs.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
Definition: cookie.c:170
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
static DWORD cb
Definition: integrity.c:41
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
int ret
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
BOOL WINAPI SetCurrentDirectoryA(IN LPCSTR lpPathName)
Definition: path.c:2205
GLenum GLsizei len
Definition: glext.h:6722
#define AIF_QUIET
Definition: advpub.h:127
#define GENERIC_READ
Definition: compat.h:124
#define err(...)
#define broken(x)
Definition: _sntprintf.h:21
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
static DWORD
Definition: files.c:33
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
Definition: files.c:277
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
static void test_AddDelBackupEntry(void)
Definition: files.c:100
#define S_OK
Definition: intsafe.h:59
#define CREATE_ALWAYS
Definition: disk.h:72
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2053
#define CDECL
Definition: compat.h:21
unsigned short USHORT
Definition: pedump.c:61
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
Definition: services.c:325
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2336
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
USHORT setID
Definition: fci.h:157
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
unsigned int UINT
Definition: ndis.h:50
#define AADBE_ADD_ENTRY
Definition: advpub.h:115
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
Definition: fci.c:1397
#define skip(...)
Definition: name.c:36
GLuint res
Definition: glext.h:9613
#define AIF_NOOVERWRITE
Definition: advpub.h:123
char szCabPath[CB_MAX_CAB_PATH]
Definition: fci.h:161
unsigned int ULONG
Definition: retypes.h:1
static BOOL check_ini_file_attr(LPSTR filename)
Definition: files.c:88
#define GetProcAddress(x, y)
Definition: compat.h:410
static CHAR CURR_DIR[MAX_PATH]
Definition: files.c:38
#define CREATE_NEW
Definition: disk.h:69
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399
static void add_file(HFCI hfci, char *file)
Definition: files.c:330
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: files.c:234
START_TEST(files)
Definition: files.c:546
#define win_skip
Definition: test.h:141
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define HeapFree(x, y, z)
Definition: compat.h:394
BOOL expected
Definition: store.c:2063
static void *CDECL mem_alloc(ULONG cb)
Definition: files.c:184
static void test_AdvInstallFile(void)
Definition: files.c:492
Definition: fci.c:126
char temp_path[MAX_PATH]
Definition: mspatcha.c:123