ReactOS  0.4.15-dev-2534-geba00d1
extract.c File Reference
#include <stdio.h>
#include <windows.h>
#include "fci.h"
#include "fdi.h"
#include "wine/test.h"
Include dependency graph for extract.c:

Go to the source code of this file.

Classes

struct  FILELIST
 
struct  SESSION
 

Macros

#define MEDIA_SIZE   999999999
 
#define FOLDER_THRESHOLD   900000
 
#define EXTRACT_FILLFILELIST   0x00000001
 
#define EXTRACT_EXTRACTFILES   0x00000002
 

Functions

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)
 

Variables

static HMODULE hCabinet
 
static LPCSTR
 
static CHAR CURR_DIR [MAX_PATH]
 

Macro Definition Documentation

◆ EXTRACT_EXTRACTFILES

#define EXTRACT_EXTRACTFILES   0x00000002

Definition at line 37 of file extract.c.

◆ EXTRACT_FILLFILELIST

#define EXTRACT_FILLFILELIST   0x00000001

Definition at line 36 of file extract.c.

◆ FOLDER_THRESHOLD

#define FOLDER_THRESHOLD   900000

Definition at line 29 of file extract.c.

◆ MEDIA_SIZE

#define MEDIA_SIZE   999999999

Definition at line 28 of file extract.c.

Function Documentation

◆ add_file()

static void add_file ( HFCI  hfci,
char file 
)
static

Definition at line 272 of file extract.c.

273 {
274  char path[MAX_PATH];
275  BOOL res;
276 
278  lstrcatA(path, "\\");
279  lstrcatA(path, file);
280 
283  ok(res, "Expected FCIAddFile to succeed\n");
284 }
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
Definition: extract.c:136
#define tcompTYPE_MSZIP
Definition: fci.h:65
static CHAR CURR_DIR[MAX_PATH]
Definition: extract.c:61
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
#define MAX_PATH
Definition: compat.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
Definition: extract.c:141
#define ok(value,...)
Definition: atltest.h:57
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv)
Definition: extract.c:246
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
Definition: fci.c:1397
GLuint res
Definition: glext.h:9613
Definition: fci.c:126

Referenced by create_cab_file().

◆ check_list()

static BOOL check_list ( struct FILELIST **  node,
const char filename,
BOOL  do_extract 
)
static

Definition at line 329 of file extract.c.

330 {
331  if (!*node)
332  return FALSE;
333 
334  if (lstrcmpA((*node)->FileName, filename))
335  return FALSE;
336 
337  if ((*node)->DoExtract != do_extract)
338  return FALSE;
339 
340  *node = (*node)->next;
341  return TRUE;
342 }
#define TRUE
Definition: types.h:120
void * next
Definition: dlist.c:360
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
const char * filename
Definition: ioapi.h:135
#define FALSE
Definition: types.h:117
Definition: dlist.c:348

Referenced by test_Extract().

◆ create_cab_file()

static void create_cab_file ( void  )
static

Definition at line 298 of file extract.c.

299 {
300  CCAB cabParams;
301  HFCI hfci;
302  ERF erf;
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";
307  BOOL res;
308 
309  set_cab_parameters(&cabParams);
310 
313  get_temp_file, &cabParams, NULL);
314 
315  ok(hfci != NULL, "Failed to create an FCI context\n");
316 
317  add_file(hfci, a_txt);
318  add_file(hfci, b_txt);
319  add_file(hfci, testdir_c_txt);
320  add_file(hfci, testdir_d_txt);
321 
323  ok(res, "Failed to flush the cabinet\n");
324 
325  res = FCIDestroy(hfci);
326  ok(res, "Failed to destroy the cabinet\n");
327 }
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
Definition: extract.c:152
static void *CDECL mem_alloc(ULONG cb)
Definition: extract.c:126
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: extract.c:188
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
char CHAR
Definition: xmlstorage.h:175
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv)
Definition: extract.c:146
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
Definition: extract.c:219
BOOL __cdecl FCIDestroy(HFCI hfci)
Definition: fci.c:1709
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
Definition: extract.c:208
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
Definition: extract.c:136
Definition: fci.h:144
#define FALSE
Definition: types.h:117
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
Definition: extract.c:227
unsigned int BOOL
Definition: ntddk_ex.h:94
Definition: fci.h:44
static void set_cab_parameters(PCCAB pCabParams)
Definition: extract.c:286
double __cdecl erf(double)
static LONG CDECL progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
Definition: extract.c:141
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: extract.c:176
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
Definition: extract.c:200
static void add_file(HFCI hfci, char *file)
Definition: extract.c:272
GLuint res
Definition: glext.h:9613
static void CDECL mem_free(void *memory)
Definition: extract.c:131

Referenced by START_TEST().

◆ create_test_files()

static void create_test_files ( void  )
static

Definition at line 95 of file extract.c.

96 {
97  int len;
98 
100  len = lstrlenA(CURR_DIR);
101 
102  if(len && (CURR_DIR[len-1] == '\\'))
103  CURR_DIR[len-1] = 0;
104 
105  createTestFile("a.txt");
106  createTestFile("b.txt");
107  CreateDirectoryA("testdir", NULL);
108  createTestFile("testdir\\c.txt");
109  createTestFile("testdir\\d.txt");
110  CreateDirectoryA("dest", NULL);
111 }
static CHAR CURR_DIR[MAX_PATH]
Definition: extract.c:61
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
#define MAX_PATH
Definition: compat.h:34
static void createTestFile(const CHAR *name)
Definition: extract.c:71
GLenum GLsizei len
Definition: glext.h:6722
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2145
#define NULL
Definition: types.h:112

Referenced by START_TEST().

◆ createTestFile()

static void createTestFile ( const CHAR name)
static

Definition at line 71 of file extract.c.

72 {
73  HANDLE file;
74  DWORD written;
75 
77  ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
78  WriteFile(file, name, strlen(name), &written, NULL);
79  WriteFile(file, "\n", strlen("\n"), &written, NULL);
81 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:598
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define GENERIC_WRITE
Definition: nt_native.h:90
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
Definition: name.c:38
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
Definition: fci.c:126

Referenced by create_test_files(), and test_Extract().

◆ delete_test_files()

static void delete_test_files ( void  )
static

Definition at line 113 of file extract.c.

114 {
115  DeleteFileA("a.txt");
116  DeleteFileA("b.txt");
117  DeleteFileA("testdir\\c.txt");
118  DeleteFileA("testdir\\d.txt");
119  RemoveDirectoryA("testdir");
120 
121  DeleteFileA("extract.cab");
122 }
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by START_TEST().

◆ fci_close()

static int CDECL fci_close ( INT_PTR  hf,
int err,
void pv 
)
static

Definition at line 200 of file extract.c.

201 {
202  HANDLE handle = (HANDLE)hf;
203  ok(CloseHandle(handle), "Failed to CloseHandle\n");
204 
205  return 0;
206 }
#define CloseHandle
Definition: compat.h:598
PVOID HANDLE
Definition: typedefs.h:73
#define ok(value,...)
Definition: atltest.h:57

Referenced by create_cab_file().

◆ fci_delete()

static int CDECL fci_delete ( char pszFile,
int err,
void pv 
)
static

Definition at line 219 of file extract.c.

220 {
221  BOOL ret = DeleteFileA(pszFile);
222  ok(ret, "Failed to DeleteFile %s\n", pszFile);
223 
224  return 0;
225 }
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
int ret
#define ok(value,...)
Definition: atltest.h:57

Referenced by create_cab_file().

◆ fci_open()

static INT_PTR CDECL fci_open ( char pszFile,
int  oflag,
int  pmode,
int err,
void pv 
)
static

Definition at line 152 of file extract.c.

153 {
154  HANDLE handle;
155  DWORD dwAccess = 0;
156  DWORD dwShareMode = 0;
157  DWORD dwCreateDisposition = OPEN_EXISTING;
158 
159  dwAccess = GENERIC_READ | GENERIC_WRITE;
160  /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
161  dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
162 
164  dwCreateDisposition = OPEN_EXISTING;
165  else
166  dwCreateDisposition = CREATE_NEW;
167 
168  handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
169  dwCreateDisposition, 0, NULL);
170 
171  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
172 
173  return (INT_PTR)handle;
174 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:64
#define FILE_SHARE_READ
Definition: compat.h:136
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
#define GENERIC_WRITE
Definition: nt_native.h:90
#define OPEN_EXISTING
Definition: compat.h:634
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define GENERIC_READ
Definition: compat.h:135
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define CREATE_NEW
Definition: disk.h:69
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599

Referenced by create_cab_file().

◆ fci_read()

static UINT CDECL fci_read ( INT_PTR  hf,
void memory,
UINT  cb,
int err,
void pv 
)
static

Definition at line 176 of file extract.c.

177 {
178  HANDLE handle = (HANDLE)hf;
179  DWORD dwRead;
180  BOOL res;
181 
182  res = ReadFile(handle, memory, cb, &dwRead, NULL);
183  ok(res, "Failed to ReadFile\n");
184 
185  return dwRead;
186 }
static char memory[1024 *256]
Definition: process.c:116
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
#define ok(value,...)
Definition: atltest.h:57
#define ReadFile(a, b, c, d, e)
Definition: compat.h:601
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
GLuint res
Definition: glext.h:9613

Referenced by create_cab_file().

◆ fci_seek()

static LONG CDECL fci_seek ( INT_PTR  hf,
LONG  dist,
int  seektype,
int err,
void pv 
)
static

Definition at line 208 of file extract.c.

209 {
210  HANDLE handle = (HANDLE)hf;
211  DWORD ret;
212 
213  ret = SetFilePointer(handle, dist, NULL, seektype);
214  ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
215 
216  return ret;
217 }
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
int ret
#define INVALID_SET_FILE_POINTER
Definition: compat.h:591
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
#define SetFilePointer
Definition: compat.h:602

Referenced by create_cab_file().

◆ fci_write()

static UINT CDECL fci_write ( INT_PTR  hf,
void memory,
UINT  cb,
int err,
void pv 
)
static

Definition at line 188 of file extract.c.

189 {
190  HANDLE handle = (HANDLE)hf;
191  DWORD dwWritten;
192  BOOL res;
193 
194  res = WriteFile(handle, memory, cb, &dwWritten, NULL);
195  ok(res, "Failed to WriteFile\n");
196 
197  return dwWritten;
198 }
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 char memory[1024 *256]
Definition: process.c:116
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32
GLuint res
Definition: glext.h:9613

Referenced by create_cab_file().

◆ file_placed()

static int CDECL file_placed ( PCCAB  pccab,
char pszFile,
LONG  cbFile,
BOOL  fContinuation,
void pv 
)
static

Definition at line 146 of file extract.c.

148 {
149  return 0;
150 }

Referenced by create_cab_file().

◆ free_file_list()

static void free_file_list ( SESSION session)
static

Definition at line 350 of file extract.c.

351 {
352  struct FILELIST *next, *curr = session->FileList;
353 
354  while (curr)
355  {
356  next = curr->next;
357  free_file_node(curr);
358  curr = next;
359  }
360 
361  session->FileList = NULL;
362 }
static void free_file_node(struct FILELIST *node)
Definition: extract.c:344
struct FILELIST * next
Definition: files.c:525
static unsigned __int64 next
Definition: rand_nt.c:6
#define NULL
Definition: types.h:112

Referenced by test_Extract().

◆ free_file_node()

static void free_file_node ( struct FILELIST node)
static

Definition at line 344 of file extract.c.

345 {
346  HeapFree(GetProcessHeap(), 0, node->FileName);
348 }
#define GetProcessHeap()
Definition: compat.h:595
#define HeapFree(x, y, z)
Definition: compat.h:594
Definition: dlist.c:348

Referenced by free_file_list(), and test_Extract().

◆ get_next_cabinet()

static BOOL CDECL get_next_cabinet ( PCCAB  pccab,
ULONG  cbPrevCab,
void pv 
)
static

Definition at line 136 of file extract.c.

137 {
138  return TRUE;
139 }
#define TRUE
Definition: types.h:120

Referenced by add_file(), and create_cab_file().

◆ get_open_info()

static INT_PTR CDECL get_open_info ( char pszName,
USHORT pdate,
USHORT ptime,
USHORT pattribs,
int err,
void pv 
)
static

Definition at line 246 of file extract.c.

248 {
251  HANDLE handle;
252  DWORD attrs;
253  BOOL res;
254 
257 
258  ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
259 
261  ok(res, "Expected GetFileInformationByHandle to succeed\n");
262 
264  FileTimeToDosDateTime(&filetime, pdate, ptime);
265 
266  attrs = GetFileAttributesA(pszName);
267  ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
268 
269  return (INT_PTR)handle;
270 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
int32_t INT_PTR
Definition: typedefs.h:64
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
#define FILE_SHARE_READ
Definition: compat.h:136
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
#define OPEN_EXISTING
Definition: compat.h:634
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:458
unsigned long DWORD
Definition: ntddk_ex.h:95
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define GENERIC_READ
Definition: compat.h:135
BOOL WINAPI FileTimeToDosDateTime(IN CONST FILETIME *lpFileTime, OUT LPWORD lpFatDate, OUT LPWORD lpFatTime)
Definition: time.c:37
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
#define ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599

Referenced by add_file().

◆ get_temp_file()

static BOOL CDECL get_temp_file ( char pszTempName,
int  cbTempName,
void pv 
)
static

Definition at line 227 of file extract.c.

228 {
229  LPSTR tempname;
230 
231  tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
232  GetTempFileNameA(".", "xx", 0, tempname);
233 
234  if (tempname && (strlen(tempname) < (unsigned)cbTempName))
235  {
236  lstrcpyA(pszTempName, tempname);
237  HeapFree(GetProcessHeap(), 0, tempname);
238  return TRUE;
239  }
240 
241  HeapFree(GetProcessHeap(), 0, tempname);
242 
243  return FALSE;
244 }
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
char * LPSTR
Definition: xmlstorage.h:182
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define MAX_PATH
Definition: compat.h:34
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
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:594

Referenced by create_cab_file().

◆ getFileSize()

static int getFileSize ( const CHAR name)
static

Definition at line 83 of file extract.c.

84 {
85  HANDLE file;
86  int size;
89  return -1;
92  return size;
93 }
#define CloseHandle
Definition: compat.h:598
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define OPEN_EXISTING
Definition: compat.h:634
GLsizeiptr size
Definition: glext.h:5919
const char file[]
Definition: icontest.c:11
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:331
#define GENERIC_READ
Definition: compat.h:135
#define NULL
Definition: types.h:112
Definition: name.c:38
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:599
Definition: fci.c:126

Referenced by test_Extract().

◆ HRESULT()

static HRESULT ( WINAPI pExtract)
static

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 63 of file extract.c.

64 {
65  hCabinet = GetModuleHandleA("cabinet.dll");
66 
67  pExtract = (void *)GetProcAddress(hCabinet, "Extract");
68 }
static HMODULE hCabinet
Definition: extract.c:58
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by START_TEST().

◆ mem_alloc()

static void* CDECL mem_alloc ( ULONG  cb)
static

Definition at line 126 of file extract.c.

127 {
128  return HeapAlloc(GetProcessHeap(), 0, cb);
129 }
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static HMODULE MODULEINFO DWORD cb
Definition: module.c:32

Referenced by create_cab_file().

◆ mem_free()

static void CDECL mem_free ( void memory)
static

Definition at line 131 of file extract.c.

132 {
134 }
static char memory[1024 *256]
Definition: process.c:116
#define GetProcessHeap()
Definition: compat.h:595
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by create_cab_file().

◆ progress()

static LONG CDECL progress ( UINT  typeStatus,
ULONG  cb1,
ULONG  cb2,
void pv 
)
static

Definition at line 141 of file extract.c.

142 {
143  return 0;
144 }

Referenced by add_file(), and create_cab_file().

◆ set_cab_parameters()

static void set_cab_parameters ( PCCAB  pCabParams)
static

Definition at line 286 of file extract.c.

287 {
288  ZeroMemory(pCabParams, sizeof(CCAB));
289 
290  pCabParams->cb = MEDIA_SIZE;
291  pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
292  pCabParams->setID = 0xbeef;
293  lstrcpyA(pCabParams->szCabPath, CURR_DIR);
294  lstrcatA(pCabParams->szCabPath, "\\");
295  lstrcpyA(pCabParams->szCab, "extract.cab");
296 }
ULONG cbFolderThresh
Definition: fci.h:146
#define ZeroMemory
Definition: winbase.h:1664
Definition: fci.h:144
static CHAR CURR_DIR[MAX_PATH]
Definition: extract.c:61
char szCab[CB_MAX_CABINET_NAME]
Definition: fci.h:160
ULONG cb
Definition: fci.h:145
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define FOLDER_THRESHOLD
Definition: extract.c:29
USHORT setID
Definition: fci.h:157
char szCabPath[CB_MAX_CAB_PATH]
Definition: fci.h:161
#define MEDIA_SIZE
Definition: extract.c:28

Referenced by create_cab_file().

◆ START_TEST()

START_TEST ( extract  )

Definition at line 716 of file extract.c.

717 {
720  create_cab_file();
721 
722  test_Extract();
723 
725 }
static void test_Extract(void)
Definition: extract.c:364
static void create_cab_file(void)
Definition: extract.c:298
static void create_test_files(void)
Definition: extract.c:95
static void init_function_pointers(void)
Definition: extract.c:63
static void delete_test_files(void)
Definition: extract.c:113

◆ test_Extract()

static void test_Extract ( void  )
static

Definition at line 364 of file extract.c.

365 {
367  HRESULT res;
368  struct FILELIST *node;
369 
370  /* native windows crashes if
371  * - invalid parameters are sent in
372  * - you call EXTRACT_EXTRACTFILES without calling
373  * EXTRACT_FILLFILELIST first or at the same time
374  */
375 
376  /* try to extract all files */
377  ZeroMemory(&session, sizeof(SESSION));
378  lstrcpyA(session.Destination, "dest");
380  res = pExtract(&session, "extract.cab");
381  node = session.FileList;
382  ok(res == S_OK, "Expected S_OK, got %d\n", res);
383  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
384  ok(session.Error.erfOper == FDIERROR_NONE,
385  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
386  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
387  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
388  ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
390  "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
391  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
392  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
400  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
401  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
402  ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
403  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
404  ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
406 
407  /* try fill file list operation */
408  ZeroMemory(&session, sizeof(SESSION));
409  lstrcpyA(session.Destination, "dest");
410  session.Operation = EXTRACT_FILLFILELIST;
411  res = pExtract(&session, "extract.cab");
412  node = session.FileList;
413  ok(res == S_OK, "Expected S_OK, got %d\n", res);
414  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
415  ok(session.Error.erfOper == FDIERROR_NONE,
416  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
417  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
418  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
419  ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
420  ok(session.Operation == EXTRACT_FILLFILELIST,
421  "Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation);
422  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
423  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
429  ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n");
430  ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n");
431  ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n");
432  ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n");
433 
434  /* try extract files operation once file list is filled */
435  session.Operation = EXTRACT_EXTRACTFILES;
436  res = pExtract(&session, "extract.cab");
437  node = session.FileList;
438  ok(res == S_OK, "Expected S_OK, got %d\n", res);
439  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
440  ok(session.Error.erfOper == FDIERROR_NONE,
441  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
442  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
443  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
444  ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
445  ok(session.Operation == EXTRACT_EXTRACTFILES,
446  "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
447  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
448  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
456  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
457  ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
458  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
459  ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
460  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
461  ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
462 
463  /* Extract does not extract files if the dest dir does not exist */
464  res = pExtract(&session, "extract.cab");
465  node = session.FileList;
466  ok(res == S_OK, "Expected S_OK, got %d\n", res);
467  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
468  ok(session.Error.erfOper == FDIERROR_NONE,
469  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
470  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
471  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
472  ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
473  ok(session.Operation == EXTRACT_EXTRACTFILES,
474  "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
475  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
476  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
484  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
485  ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
486  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
487  ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
488 
489  /* remove two of the files in the list */
490  node = session.FileList->next;
491  session.FileList->next = session.FileList->next->next;
493  free_file_node(session.FileList->next->next);
494  session.FileList->next->next = NULL;
495  session.FilterList = NULL;
496  CreateDirectoryA("dest", NULL);
497  res = pExtract(&session, "extract.cab");
498  node = session.FileList;
499  ok(res == S_OK, "Expected S_OK, got %d\n", res);
500  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
501  ok(session.Error.erfOper == FDIERROR_NONE,
502  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
503  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
504  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
505  ok(session.FileCount == 4, "Expected 4, got %d\n", session.FileCount);
506  ok(session.Operation == EXTRACT_EXTRACTFILES,
507  "Expected EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
508  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
509  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
517  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
518  ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
519  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
520  ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n");
522 
523  session.Operation = EXTRACT_FILLFILELIST;
524  session.FileList = NULL;
525  res = pExtract(&session, "extract.cab");
526  node = session.FileList;
527  ok(res == S_OK, "Expected S_OK, got %d\n", res);
528  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
529  ok(session.Error.erfOper == FDIERROR_NONE,
530  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
531  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
532  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
533  ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
534  ok(session.Operation == EXTRACT_FILLFILELIST,
535  "Expected EXTRACT_FILLFILELIST, got %d\n", session.Operation);
536  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
537  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
545  ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n");
546  ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
547  ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n");
548  ok(!check_list(&node, "a.txt", FALSE), "list entry wrong\n");
549 
550  session.Operation = 0;
551  res = pExtract(&session, "extract.cab");
552  node = session.FileList;
553  ok(res == S_OK, "Expected S_OK, got %d\n", res);
554  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
555  ok(session.Error.erfOper == FDIERROR_NONE,
556  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
557  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
558  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
559  ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
560  ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation);
561  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
562  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
570  ok(check_list(&node, "testdir\\d.txt", TRUE), "list entry wrong\n");
571  ok(check_list(&node, "testdir\\c.txt", TRUE), "list entry wrong\n");
572  ok(check_list(&node, "b.txt", TRUE), "list entry wrong\n");
573  ok(check_list(&node, "a.txt", TRUE), "list entry wrong\n");
574 
575  session.Operation = 0;
576  session.FilterList = session.FileList;
577  res = pExtract(&session, "extract.cab");
578  node = session.FileList;
579  ok(res == S_OK, "Expected S_OK, got %d\n", res);
580  ok(session.FileSize == 40, "Expected 40, got %d\n", session.FileSize);
581  ok(session.Error.erfOper == FDIERROR_NONE,
582  "Expected FDIERROR_NONE, got %d\n", session.Error.erfOper);
583  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
584  ok(session.Error.fError == FALSE, "Expected FALSE, got %d\n", session.Error.fError);
585  ok(session.FileCount == 8, "Expected 8, got %d\n", session.FileCount);
586  ok(session.Operation == 0, "Expected 0, got %d\n", session.Operation);
587  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
588  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\d.txt"),
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");
595  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
596  ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
597  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
598  ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
599  node = session.FilterList;
600  ok(check_list(&node, "testdir\\d.txt", FALSE), "list entry wrong\n");
601  ok(check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
602  ok(check_list(&node, "b.txt", FALSE), "list entry wrong\n");
603  ok(check_list(&node, "a.txt", FALSE), "list entry wrong\n");
605 
606  /* cabinet does not exist */
607  ZeroMemory(&session, sizeof(SESSION));
608  lstrcpyA(session.Destination, "dest");
610  res = pExtract(&session, "nonexistent.cab");
611  node = session.FileList;
613  "Expected HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), got %08x\n", res);
614  ok(session.Error.erfOper == FDIERROR_CABINET_NOT_FOUND,
615  "Expected FDIERROR_CABINET_NOT_FOUND, got %d\n", session.Error.erfOper);
616  ok(session.FileSize == 0, "Expected 0, got %d\n", session.FileSize);
617  ok(session.Error.erfType == 0, "Expected 0, got %d\n", session.Error.erfType);
618  ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
619  ok(session.FileCount == 0, "Expected 0, got %d\n", session.FileCount);
621  "Expected EXTRACT_FILLFILELIST | EXTRACT_EXTRACTFILES, got %d\n", session.Operation);
622  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
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");
630  ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
631  ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n");
632  ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
633  ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
635 
636  /* first file exists but is read-only */
637  createTestFile("dest\\a.txt");
639  ok(getFileSize("dest\\a.txt") == 11, "Expected dest\\a.txt to be 11 bytes\n");
640  ZeroMemory(&session, sizeof(SESSION));
641  lstrcpyA(session.Destination, "dest");
643  res = pExtract(&session, "extract.cab");
644  node = session.FileList;
646  "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res);
647  ok(session.FileSize == 6, "Expected 6, got %d\n", session.FileSize);
648  ok(session.Error.erfOper == FDIERROR_USER_ABORT,
649  "Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper);
650  ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
651  ok(session.FileCount == 1, "Expected 1, got %d\n", session.FileCount);
652  ok(!lstrcmpA(session.CurrentFile, "dest\\a.txt"),
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);
657  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
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");
665  ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
666  ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry should not exist\n");
667  ok(!check_list(&node, "b.txt", FALSE), "list entry should not exist\n");
668  ok(!check_list(&node, "a.txt", FALSE), "list entry should not exist\n");
670 
672  DeleteFileA("dest\\a.txt");
673 
674  /* first file exists and is writable, third file exists but is read-only */
675  createTestFile("dest\\a.txt");
676  createTestFile("dest\\testdir\\c.txt");
677  SetFileAttributesA("dest\\testdir\\c.txt", FILE_ATTRIBUTE_READONLY);
678  ZeroMemory(&session, sizeof(SESSION));
679  lstrcpyA(session.Destination, "dest");
681  res = pExtract(&session, "extract.cab");
682  node = session.FileList;
684  "Expected HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED) or E_FAIL, got %08x\n", res);
685  ok(session.FileSize == 26, "Expected 26, got %d\n", session.FileSize);
686  ok(session.Error.erfOper == FDIERROR_USER_ABORT,
687  "Expected FDIERROR_USER_ABORT, got %d\n", session.Error.erfOper);
688  ok(session.Error.fError == TRUE, "Expected TRUE, got %d\n", session.Error.fError);
689  ok(session.FileCount == 3, "Expected 3, got %d\n", session.FileCount);
690  ok(!lstrcmpA(session.CurrentFile, "dest\\testdir\\c.txt"),
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);
695  ok(!lstrcmpA(session.Destination, "dest"), "Expected dest, got %s\n", session.Destination);
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");
703  ok(!check_list(&node, "testdir\\d.txt", FALSE), "list entry should not exist\n");
704  ok(!check_list(&node, "testdir\\c.txt", FALSE), "list entry wrong\n");
705  ok(!check_list(&node, "b.txt", FALSE), "list entry wrong\n");
706  ok(!check_list(&node, "a.txt", TRUE), "list entry wrong\n");
708 
709  SetFileAttributesA("dest\\testdir\\c.txt", FILE_ATTRIBUTE_NORMAL);
710  DeleteFileA("dest\\testdir\\c.txt");
711 
712  ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
713  ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
714 }
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define TRUE
Definition: types.h:120
static int getFileSize(const CHAR *name)
Definition: extract.c:83
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
#define ZeroMemory
Definition: winbase.h:1664
static BOOL check_list(struct FILELIST **node, const char *filename, BOOL do_extract)
Definition: extract.c:329
#define E_FAIL
Definition: ddrawi.h:102
struct node node
static void free_file_node(struct FILELIST *node)
Definition: extract.c:344
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI SetFileAttributesA(LPCSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:776
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
LONG HRESULT
Definition: typedefs.h:79
Definition: files.c:529
#define FILE_ATTRIBUTE_READONLY
Definition: nt_native.h:702
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
#define EXTRACT_EXTRACTFILES
Definition: extract.c:37
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
static void createTestFile(const CHAR *name)
Definition: extract.c:71
#define S_OK
Definition: intsafe.h:51
#define ok(value,...)
Definition: atltest.h:57
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714
#define NULL
Definition: types.h:112
GLuint res
Definition: glext.h:9613
#define EXTRACT_FILLFILELIST
Definition: extract.c:36
static void free_file_list(SESSION *session)
Definition: extract.c:350
Definition: dlist.c:348

Referenced by START_TEST().

Variable Documentation

◆ CURR_DIR

CHAR CURR_DIR[MAX_PATH]
static

Definition at line 61 of file extract.c.

Referenced by add_file(), create_test_files(), and set_cab_parameters().

◆ hCabinet

HMODULE hCabinet
static

Definition at line 58 of file extract.c.

Referenced by init_function_pointers().

◆ LPCSTR

Definition at line 59 of file extract.c.