#include <stdio.h>
#include <windows.h>
#include "fci.h"
#include "fdi.h"
#include "wine/test.h"
Go to the source code of this file.
|
static | HRESULT (WINAPI *pExtract)(SESSION * |
|
static void | init_function_pointers (void) |
|
static void | createTestFile (const CHAR *name) |
|
static int | getFileSize (const CHAR *name) |
|
static void | create_test_files (void) |
|
static void | delete_test_files (void) |
|
static void *CDECL | mem_alloc (ULONG cb) |
|
static void CDECL | mem_free (void *memory) |
|
static BOOL CDECL | get_next_cabinet (PCCAB pccab, ULONG cbPrevCab, void *pv) |
|
static LONG CDECL | progress (UINT typeStatus, ULONG cb1, ULONG cb2, void *pv) |
|
static int CDECL | file_placed (PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv) |
|
static INT_PTR CDECL | fci_open (char *pszFile, int oflag, int pmode, int *err, void *pv) |
|
static UINT CDECL | fci_read (INT_PTR hf, void *memory, UINT cb, int *err, void *pv) |
|
static UINT CDECL | fci_write (INT_PTR hf, void *memory, UINT cb, int *err, void *pv) |
|
static int CDECL | fci_close (INT_PTR hf, int *err, void *pv) |
|
static LONG CDECL | fci_seek (INT_PTR hf, LONG dist, int seektype, int *err, void *pv) |
|
static int CDECL | fci_delete (char *pszFile, int *err, void *pv) |
|
static BOOL CDECL | get_temp_file (char *pszTempName, int cbTempName, void *pv) |
|
static INT_PTR CDECL | get_open_info (char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv) |
|
static void | add_file (HFCI hfci, char *file) |
|
static void | set_cab_parameters (PCCAB pCabParams) |
|
static void | create_cab_file (void) |
|
static BOOL | check_list (struct FILELIST **node, const char *filename, BOOL do_extract) |
|
static void | free_file_node (struct FILELIST *node) |
|
static void | free_file_list (SESSION *session) |
|
static void | test_Extract (void) |
|
| START_TEST (extract) |
|
◆ EXTRACT_EXTRACTFILES
#define EXTRACT_EXTRACTFILES 0x00000002 |
◆ EXTRACT_FILLFILELIST
#define EXTRACT_FILLFILELIST 0x00000001 |
◆ FOLDER_THRESHOLD
#define FOLDER_THRESHOLD 900000 |
◆ MEDIA_SIZE
◆ add_file()
Definition at line 272 of file extract.c.
273{
276
280
283 ok(
res,
"Expected FCIAddFile to succeed\n");
284}
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Referenced by create_cab_file().
◆ check_list()
Definition at line 329 of file extract.c.
330{
333
336
337 if ((*node)->DoExtract != do_extract)
339
342}
int WINAPI lstrcmpA(LPCSTR str1, LPCSTR str2)
Referenced by test_Extract().
◆ create_cab_file()
Definition at line 298 of file extract.c.
299{
303 static CHAR a_txt[] =
"a.txt",
304 b_txt[] = "b.txt",
305 testdir_c_txt[] = "testdir\\c.txt",
306 testdir_d_txt[] = "testdir\\d.txt";
308
310
314
315 ok(hfci !=
NULL,
"Failed to create an FCI context\n");
316
321
323 ok(
res,
"Failed to flush the cabinet\n");
324
326 ok(
res,
"Failed to destroy the cabinet\n");
327}
#define mem_free(ptr, bsize)
BOOL __cdecl FCIDestroy(HFCI hfci)
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)
BOOL __cdecl FCIFlushCabinet(HFCI hfci, BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis)
double __cdecl erf(double)
Referenced by START_TEST().
◆ create_test_files()
Definition at line 95 of file extract.c.
96{
98
101
104
111}
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
int WINAPI lstrlenA(LPCSTR lpString)
Referenced by START_TEST().
◆ createTestFile()
Definition at line 71 of file extract.c.
72{
75
81}
ACPI_SIZE strlen(const char *String)
#define INVALID_HANDLE_VALUE
#define CreateFileA(a, b, c, d, e, f, g)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Referenced by create_test_files(), and test_Extract().
◆ delete_test_files()
Definition at line 113 of file extract.c.
114{
120
122}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Referenced by START_TEST().
◆ fci_close()
◆ fci_delete()
◆ fci_open()
Definition at line 152 of file extract.c.
153{
156 DWORD dwShareMode = 0;
158
160
162
165 else
167
169 dwCreateDisposition, 0,
NULL);
170
172
174}
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
#define INVALID_FILE_ATTRIBUTES
Referenced by create_cab_file().
◆ fci_read()
Definition at line 176 of file extract.c.
177{
181
183 ok(
res,
"Failed to ReadFile\n");
184
185 return dwRead;
186}
#define ReadFile(a, b, c, d, e)
static HMODULE MODULEINFO DWORD cb
static char memory[1024 *256]
Referenced by create_cab_file().
◆ fci_seek()
◆ fci_write()
◆ file_placed()
◆ free_file_list()
Definition at line 350 of file extract.c.
351{
353
354 while (curr)
355 {
359 }
360
362}
static unsigned __int64 next
Referenced by test_Extract().
◆ free_file_node()
◆ get_next_cabinet()
◆ get_open_info()
Definition at line 246 of file extract.c.
248{
254
257
259
261 ok(
res,
"Expected GetFileInformationByHandle to succeed\n");
262
265
268
270}
#define FILE_ATTRIBUTE_NORMAL
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
#define FILE_FLAG_SEQUENTIAL_SCAN
Referenced by add_file().
◆ get_temp_file()
Definition at line 227 of file extract.c.
228{
230
233
234 if (tempname && (
strlen(tempname) < (
unsigned)cbTempName))
235 {
239 }
240
242
244}
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Referenced by create_cab_file().
◆ getFileSize()
Definition at line 83 of file extract.c.
84{
89 return -1;
93}
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Referenced by test_Extract().
◆ HRESULT()
◆ init_function_pointers()
static void init_function_pointers |
( |
void |
| ) |
|
|
static |
Definition at line 63 of file extract.c.
64{
66
68}
#define GetProcAddress(x, y)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Referenced by START_TEST().
◆ mem_alloc()
◆ mem_free()
◆ progress()
◆ set_cab_parameters()
static void set_cab_parameters |
( |
PCCAB |
pCabParams | ) |
|
|
static |
Definition at line 286 of file extract.c.
287{
289
292 pCabParams->
setID = 0xbeef;
296}
char szCabPath[CB_MAX_CAB_PATH]
char szCab[CB_MAX_CABINET_NAME]
Referenced by create_cab_file().
◆ START_TEST()
◆ test_Extract()
Definition at line 364 of file extract.c.
365{
369
370
371
372
373
374
375
376
385 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
386 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
390 "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
393 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
394 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
395 ok(!
session.FilterList,
"Expected empty filter list\n");
396 ok(
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
397 ok(
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to exist\n");
398 ok(
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to exist\n");
399 ok(
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to exist\n");
406
407
416 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
417 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
421 "Expected EXTRACT_FILLFILELIST, got %d\n",
session.Operation);
424 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
425 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
426 ok(!
session.FilterList,
"Expected empty filter list\n");
427 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to not exist\n");
428 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to not exist\n");
433
434
441 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
442 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
446 "Expected EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
449 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
450 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
451 ok(!
session.FilterList,
"Expected empty filter list\n");
452 ok(
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
453 ok(
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to exist\n");
454 ok(
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to exist\n");
455 ok(
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to exist\n");
462
463
469 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
470 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
474 "Expected EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
477 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
478 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
479 ok(!
session.FilterList,
"Expected empty filter list\n");
480 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to not exist\n");
481 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to not exist\n");
482 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to not exist\n");
483 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
488
489
502 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
503 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
507 "Expected EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
510 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
511 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
512 ok(!
session.FilterList,
"Expected empty filter list\n");
513 ok(
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
514 ok(
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to exist\n");
515 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to not exist\n");
516 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
522
530 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
531 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
535 "Expected EXTRACT_FILLFILELIST, got %d\n",
session.Operation);
538 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
539 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
540 ok(!
session.FilterList,
"Expected empty filter list\n");
541 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to not exist\n");
542 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to not exist\n");
543 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to not exist\n");
544 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
549
556 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
557 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
563 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
564 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
565 ok(!
session.FilterList,
"Expected empty filter list\n");
566 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
567 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to exist\n");
568 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to exist\n");
569 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to exist\n");
574
582 "Expected FDIERROR_NONE, got %d\n",
session.Error.erfOper);
583 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
589 "Expected dest\\testdir\\d.txt, got %s\n",
session.CurrentFile);
590 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
591 ok(
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
592 ok(
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to exist\n");
593 ok(
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to exist\n");
594 ok(
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to exist\n");
605
606
613 "Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %08x\n",
res);
615 "Expected FDIERROR_CABINET_NOT_FOUND, got %d\n",
session.Error.erfOper);
617 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
621 "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
623 ok(!*
session.CurrentFile,
"Expected empty string, got %s\n",
session.CurrentFile);
624 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
625 ok(!
session.FilterList,
"Expected empty filter list\n");
626 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to not exist\n");
627 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to not exist\n");
628 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to not exist\n");
629 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
635
636
639 ok(
getFileSize(
"dest\\a.txt") == 11,
"Expected dest\\a.txt to be 11 bytes\n");
646 "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n",
res);
649 "Expected FDIERROR_USER_ABORT, got %d\n",
session.Error.erfOper);
653 "Expected dest\\a.txt, got %s\n",
session.CurrentFile);
654 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
656 "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
658 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
659 ok(!
session.FilterList,
"Expected empty filter list\n");
660 ok(
getFileSize(
"dest\\a.txt") == 11,
"Expected dest\\a.txt to be 11 bytes\n");
661 ok(!
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to be read-only\n");
662 ok(!
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to not exist\n");
663 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to not exist\n");
664 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
670
673
674
684 "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n",
res);
687 "Expected FDIERROR_USER_ABORT, got %d\n",
session.Error.erfOper);
691 "Expected dest\\c.txt, got %s\n",
session.CurrentFile);
692 ok(
session.Error.erfType == 0,
"Expected 0, got %d\n",
session.Error.erfType);
694 "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n",
session.Operation);
696 ok(!*
session.Reserved,
"Expected empty string, got %s\n",
session.Reserved);
697 ok(!
session.FilterList,
"Expected empty filter list\n");
698 ok(
getFileSize(
"dest\\a.txt") == 6,
"Expected dest\\a.txt to be 6 bytes\n");
699 ok(
DeleteFileA(
"dest\\a.txt"),
"Expected dest\\a.txt to exist\n");
700 ok(
DeleteFileA(
"dest\\b.txt"),
"Expected dest\\b.txt to exist\n");
701 ok(!
DeleteFileA(
"dest\\testdir\\c.txt"),
"Expected dest\\testdir\\c.txt to be read-only\n");
702 ok(!
DeleteFileA(
"dest\\testdir\\d.txt"),
"Expected dest\\testdir\\d.txt to not exist\n");
708
711
714}
#define ERROR_ACCESS_DENIED
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
@ FDIERROR_CABINET_NOT_FOUND
#define ERROR_FILE_NOT_FOUND
#define FILE_ATTRIBUTE_READONLY
#define HRESULT_FROM_WIN32(x)
Referenced by START_TEST().
◆ CURR_DIR
◆ hCabinet
◆ LPCSTR