ReactOS 0.4.16-dev-1998-g617f3bd
fdi.c File Reference
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <windows.h>
#include "fci.h"
#include "fdi.h"
#include "wine/test.h"
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for fdi.c:

Go to the source code of this file.

Classes

struct  CFHEADER
 
struct  CFFOLDER
 
struct  CFFILE
 
struct  CFDATA
 
struct  mem_data
 

Macros

#define MEDIA_SIZE   999999999
 
#define FOLDER_THRESHOLD   900000
 

Functions

static void *CDECL fdi_alloc (ULONG cb)
 
static void *CDECL fdi_alloc_bad (ULONG cb)
 
static void CDECL fdi_free (void *pv)
 
static INT_PTR CDECL fdi_open (char *pszFile, int oflag, int pmode)
 
static UINT CDECL fdi_read (INT_PTR hf, void *pv, UINT cb)
 
static UINT CDECL fdi_write (INT_PTR hf, void *pv, UINT cb)
 
static int CDECL fdi_close (INT_PTR hf)
 
static LONG CDECL fdi_seek (INT_PTR hf, LONG dist, int seektype)
 
static INT_PTR CDECL fdi_open_static (char *pszFile, int oflag, int pmode)
 
static UINT CDECL fdi_read_static (INT_PTR hf, void *pv, UINT cb)
 
static UINT CDECL fdi_write_static (INT_PTR hf, void *pv, UINT cb)
 
static int CDECL fdi_close_static (INT_PTR hf)
 
static LONG CDECL fdi_seek_static (INT_PTR hf, LONG dist, int seektype)
 
static void test_FDICreate (void)
 
static void test_FDIDestroy (void)
 
static void createTestFile (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 void test_FDIIsCabinet (void)
 
static INT_PTR __cdecl CopyProgress (FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
 
static INT_PTR CDECL fdi_mem_open (char *name, int oflag, int pmode)
 
static UINT CDECL fdi_mem_read (INT_PTR hf, void *pv, UINT cb)
 
static UINT CDECL fdi_mem_write (INT_PTR hf, void *pv, UINT cb)
 
static int CDECL fdi_mem_close (INT_PTR hf)
 
static LONG CDECL fdi_mem_seek (INT_PTR hf, LONG dist, int seektype)
 
static INT_PTR CDECL fdi_mem_notify (FDINOTIFICATIONTYPE fdint, FDINOTIFICATION *info)
 
static void test_FDICopy (void)
 
 START_TEST (fdi)
 

Variables

static CHAR CURR_DIR [MAX_PATH]
 
struct {
   struct CFHEADER   header
 
   struct CFFOLDER   folder
 
   struct CFFILE   file
 
   UCHAR   szName [sizeof("file.dat")]
 
   struct CFDATA   data
 
   UCHAR   ab [sizeof("Hello World!") -1]
 
cab_data
 
static INT_PTR static_fdi_handle
 

Macro Definition Documentation

◆ FOLDER_THRESHOLD

#define FOLDER_THRESHOLD   900000

Definition at line 32 of file fdi.c.

◆ MEDIA_SIZE

#define MEDIA_SIZE   999999999

Definition at line 31 of file fdi.c.

Function Documentation

◆ add_file()

static void add_file ( HFCI  hfci,
char file 
)
static

Definition at line 581 of file fdi.c.

582{
583 char path[MAX_PATH];
584 BOOL res;
585
587 lstrcatA(path, "\\");
589
592 ok(res, "Expected FCIAddFile to succeed\n");
593}
#define ok(value,...)
Definition: atltest.h:57
cd_progress_ptr progress
Definition: cdjpeg.h:152
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
BOOL __cdecl FCIAddFile(HFCI hfci, char *pszSourceFile, char *pszFileName, BOOL fExecute, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis, PFNFCIGETOPENINFO pfnfcigoi, TCOMP typeCompress)
Definition: fci.c:1397
#define tcompTYPE_MSZIP
Definition: fci.h:65
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint res
Definition: glext.h:9613
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
LPSTR WINAPI lstrcatA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:123
static CHAR CURR_DIR[MAX_PATH]
Definition: fdi.c:34
static BOOL CDECL get_next_cabinet(PCCAB pccab, ULONG cbPrevCab, void *pv)
Definition: fdi.c:442
static INT_PTR CDECL get_open_info(char *pszName, USHORT *pdate, USHORT *ptime, USHORT *pattribs, int *err, void *pv)
Definition: fdi.c:552
Definition: fci.c:127

Referenced by create_cab_file().

◆ CopyProgress()

static INT_PTR __cdecl CopyProgress ( FDINOTIFICATIONTYPE  fdint,
PFDINOTIFICATION  pfdin 
)
static

Definition at line 730 of file fdi.c.

731{
732 return 37; /* doc says 0, but anything != -1 apparently means success as well */
733}

Referenced by test_FDICopy().

◆ create_cab_file()

static void create_cab_file ( void  )
static

Definition at line 607 of file fdi.c.

608{
609 CCAB cabParams;
610 HFCI hfci;
611 ERF erf;
612 static CHAR a_txt[] = "a.txt",
613 b_txt[] = "b.txt",
614 testdir_c_txt[] = "testdir\\c.txt",
615 testdir_d_txt[] = "testdir\\d.txt";
616 BOOL res;
617
618 set_cab_parameters(&cabParams);
619
622 get_temp_file, &cabParams, NULL);
623
624 ok(hfci != NULL, "Failed to create an FCI context\n");
625
626 add_file(hfci, a_txt);
627 add_file(hfci, b_txt);
628 add_file(hfci, testdir_c_txt);
629 add_file(hfci, testdir_d_txt);
630
632 ok(res, "Failed to flush the cabinet\n");
633
634 res = FCIDestroy(hfci);
635 ok(res, "Failed to destroy the cabinet\n");
636}
#define mem_free(ptr, bsize)
Definition: types.h:124
#define NULL
Definition: types.h:112
#define mem_alloc(bsize)
Definition: types.h:123
BOOL __cdecl FCIDestroy(HFCI hfci)
Definition: fci.c:1709
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
BOOL __cdecl FCIFlushCabinet(HFCI hfci, BOOL fGetNextCab, PFNFCIGETNEXTCABINET pfnfcignc, PFNFCISTATUS pfnfcis)
Definition: fci.c:1675
double __cdecl erf(double)
static UINT CDECL fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: fdi.c:494
static void add_file(HFCI hfci, char *file)
Definition: fdi.c:581
static BOOL CDECL get_temp_file(char *pszTempName, int cbTempName, void *pv)
Definition: fdi.c:533
static void set_cab_parameters(PCCAB pCabParams)
Definition: fdi.c:595
static UINT CDECL fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
Definition: fdi.c:482
static INT_PTR CDECL fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
Definition: fdi.c:458
static int CDECL fci_delete(char *pszFile, int *err, void *pv)
Definition: fdi.c:525
static int CDECL file_placed(PCCAB pccab, char *pszFile, LONG cbFile, BOOL fContinuation, void *pv)
Definition: fdi.c:452
static LONG CDECL fci_seek(INT_PTR hf, LONG dist, int seektype, int *err, void *pv)
Definition: fdi.c:514
static int CDECL fci_close(INT_PTR hf, int *err, void *pv)
Definition: fdi.c:506
Definition: fci.h:144
Definition: fci.h:44
char CHAR
Definition: xmlstorage.h:175

Referenced by test_FDIIsCabinet().

◆ create_test_files()

static void create_test_files ( void  )
static

Definition at line 410 of file fdi.c.

411{
412 createTestFile("a.txt");
413 createTestFile("b.txt");
414 CreateDirectoryA("testdir", NULL);
415 createTestFile("testdir\\c.txt");
416 createTestFile("testdir\\d.txt");
417}
BOOL WINAPI CreateDirectoryA(IN LPCSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:37
static void createTestFile(const CHAR *name)
Definition: fdi.c:398

Referenced by test_FDIIsCabinet().

◆ createTestFile()

static void createTestFile ( const CHAR name)
static

Definition at line 398 of file fdi.c.

399{
400 HANDLE file;
401 DWORD written;
402
404 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
405 WriteFile(file, name, strlen(name), &written, NULL);
406 WriteFile(file, "\n", strlen("\n"), &written, NULL);
408}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define CREATE_ALWAYS
Definition: disk.h:72
#define GENERIC_WRITE
Definition: nt_native.h:90
Definition: name.c:39

Referenced by create_test_files(), and test_FDIIsCabinet().

◆ delete_test_files()

static void delete_test_files ( void  )
static

Definition at line 419 of file fdi.c.

420{
421 DeleteFileA("a.txt");
422 DeleteFileA("b.txt");
423 DeleteFileA("testdir\\c.txt");
424 DeleteFileA("testdir\\d.txt");
425 RemoveDirectoryA("testdir");
426
427 DeleteFileA("extract.cab");
428}
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
BOOL WINAPI RemoveDirectoryA(IN LPCSTR lpPathName)
Definition: dir.c:714

Referenced by test_FDIIsCabinet().

◆ fci_close()

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

Definition at line 506 of file fdi.c.

507{
508 HANDLE handle = (HANDLE)hf;
509 ok(CloseHandle(handle), "Failed to CloseHandle\n");
510
511 return 0;
512}
PVOID HANDLE
Definition: typedefs.h:73

Referenced by create_cab_file(), and test_FDICopy().

◆ fci_delete()

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

Definition at line 525 of file fdi.c.

526{
527 BOOL ret = DeleteFileA(pszFile);
528 ok(ret, "Failed to DeleteFile %s\n", pszFile);
529
530 return 0;
531}
return ret
Definition: mutex.c:146

Referenced by create_cab_file(), and test_FDICopy().

◆ fci_open()

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

Definition at line 458 of file fdi.c.

459{
461 DWORD dwAccess = 0;
462 DWORD dwShareMode = 0;
463 DWORD dwCreateDisposition = OPEN_EXISTING;
464
465 dwAccess = GENERIC_READ | GENERIC_WRITE;
466 /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
467 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
468
470 dwCreateDisposition = OPEN_EXISTING;
471 else
472 dwCreateDisposition = CREATE_NEW;
473
474 handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
475 dwCreateDisposition, 0, NULL);
476
477 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
478
479 return (INT_PTR)handle;
480}
#define OPEN_EXISTING
Definition: compat.h:775
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
DWORD WINAPI GetFileAttributesA(LPCSTR lpFileName)
Definition: fileinfo.c:636
#define CREATE_NEW
Definition: disk.h:69
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
int32_t INT_PTR
Definition: typedefs.h:64
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

Referenced by create_cab_file(), and test_FDICopy().

◆ fci_read()

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

Definition at line 482 of file fdi.c.

483{
484 HANDLE handle = (HANDLE)hf;
485 DWORD dwRead;
486 BOOL res;
487
488 res = ReadFile(handle, memory, cb, &dwRead, NULL);
489 ok(res, "Failed to ReadFile\n");
490
491 return dwRead;
492}
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static char memory[1024 *256]
Definition: process.c:116

Referenced by create_cab_file(), and test_FDICopy().

◆ fci_seek()

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

Definition at line 514 of file fdi.c.

515{
516 HANDLE handle = (HANDLE)hf;
517 DWORD ret;
518
519 ret = SetFilePointer(handle, dist, NULL, seektype);
520 ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
521
522 return ret;
523}
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define SetFilePointer
Definition: compat.h:743

Referenced by create_cab_file(), and test_FDICopy().

◆ fci_write()

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

Definition at line 494 of file fdi.c.

495{
496 HANDLE handle = (HANDLE)hf;
497 DWORD dwWritten;
498 BOOL res;
499
500 res = WriteFile(handle, memory, cb, &dwWritten, NULL);
501 ok(res, "Failed to WriteFile\n");
502
503 return dwWritten;
504}

Referenced by create_cab_file(), and test_FDICopy().

◆ fdi_alloc()

static void *CDECL fdi_alloc ( ULONG  cb)
static

Definition at line 127 of file fdi.c.

128{
129 return HeapAlloc(GetProcessHeap(), 0, cb);
130}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733

Referenced by test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_alloc_bad()

static void *CDECL fdi_alloc_bad ( ULONG  cb)
static

Definition at line 132 of file fdi.c.

133{
134 return NULL;
135}

Referenced by test_FDICreate().

◆ fdi_close()

static int CDECL fdi_close ( INT_PTR  hf)
static

Definition at line 170 of file fdi.c.

171{
172 HANDLE handle = (HANDLE) hf;
173 return CloseHandle(handle) ? 0 : -1;
174}

Referenced by test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_close_static()

static int CDECL fdi_close_static ( INT_PTR  hf)
static

Definition at line 203 of file fdi.c.

204{
205 ok(0, "FDIIsCabinet shouldn't call pfnclose\n");
206 return 0;
207}

Referenced by test_FDIIsCabinet().

◆ fdi_free()

static void CDECL fdi_free ( void pv)
static

Definition at line 137 of file fdi.c.

138{
139 HeapFree(GetProcessHeap(), 0, pv);
140}
#define HeapFree(x, y, z)
Definition: compat.h:735

Referenced by test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_mem_close()

static int CDECL fdi_mem_close ( INT_PTR  hf)
static

Definition at line 783 of file fdi.c.

784{
785 HeapFree(GetProcessHeap(), 0, (void *)hf);
786 return 0;
787}

Referenced by test_FDICopy().

◆ fdi_mem_notify()

static INT_PTR CDECL fdi_mem_notify ( FDINOTIFICATIONTYPE  fdint,
FDINOTIFICATION info 
)
static

Definition at line 816 of file fdi.c.

817{
818 static const char expected[9] = "file.dat\0";
819
820 switch (fdint)
821 {
823 trace("mem_notify: CLOSE_FILE_INFO %s, handle %#Ix\n", info->psz1, info->hf);
824
825 ok(!strcmp(info->psz1, expected), "expected %s, got %s\n", expected, info->psz1);
826 ok(info->date == 0x1225, "expected 0x1225, got %#x\n", info->date);
827 ok(info->time == 0x2013, "expected 0x2013, got %#x\n", info->time);
828 ok(info->attribs == 0xa114, "expected 0xa114, got %#x\n", info->attribs);
829 ok(info->iFolder == 0x1234, "expected 0x1234, got %#x\n", info->iFolder);
830 return 1;
831
832 case fdintCOPY_FILE:
833 {
834 trace("mem_notify: COPY_FILE %s, %ld bytes\n", info->psz1, info->cb);
835
836 ok(info->cb == 12, "expected 12, got %lu\n", info->cb);
837 ok(!strcmp(info->psz1, expected), "expected %s, got %s\n", expected, info->psz1);
838 ok(info->iFolder == 0x1234, "expected 0x1234, got %#x\n", info->iFolder);
839 return 0x12345678; /* call write() callback */
840 }
841
842 default:
843 trace("mem_notify(%d,%p)\n", fdint, info);
844 return 0;
845 }
846
847 return 0;
848}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define trace
Definition: atltest.h:70
@ fdintCOPY_FILE
Definition: fdi.h:249
@ fdintCLOSE_FILE_INFO
Definition: fdi.h:250
BOOL expected
Definition: store.c:2000

Referenced by test_FDICopy().

◆ fdi_mem_open()

static INT_PTR CDECL fdi_mem_open ( char name,
int  oflag,
int  pmode 
)
static

Definition at line 735 of file fdi.c.

736{
737 static const char expected[] = "memory\\block";
738 struct mem_data *data;
739
740 ok(!strcmp(name, expected), "expected %s, got %s\n", expected, name);
741 ok(oflag == _O_BINARY, "expected _O_BINARY, got %x\n", oflag);
742 ok(pmode == (_S_IREAD | _S_IWRITE), "expected _S_IREAD | _S_IWRITE, got %x\n", pmode);
743
744 data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data));
745 if (!data) return -1;
746
747 data->base = (const char *)&cab_data;
748 data->size = sizeof(cab_data);
749 data->pos = 0;
750
751 trace("mem_open(%s,%x,%x) => %p\n", name, oflag, pmode, data);
752 return (INT_PTR)data;
753}
#define _S_IWRITE
Definition: stat.h:85
#define _S_IREAD
Definition: stat.h:84
#define _O_BINARY
Definition: cabinet.h:51
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const struct @1778 cab_data
Definition: fdi.c:120

Referenced by test_FDICopy().

◆ fdi_mem_read()

static UINT CDECL fdi_mem_read ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 755 of file fdi.c.

756{
757 struct mem_data *data = (struct mem_data *)hf;
758 UINT available, cb_read;
759
760 available = data->size - data->pos;
761 cb_read = (available >= cb) ? cb : available;
762
763 memcpy(pv, data->base + data->pos, cb_read);
764 data->pos += cb_read;
765
766 /*trace("mem_read(%p,%p,%u) => %u\n", hf, pv, cb, cb_read);*/
767 return cb_read;
768}
static WCHAR available[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2336
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int UINT
Definition: ndis.h:50

Referenced by test_FDICopy().

◆ fdi_mem_seek()

static LONG CDECL fdi_mem_seek ( INT_PTR  hf,
LONG  dist,
int  seektype 
)
static

Definition at line 789 of file fdi.c.

790{
791 struct mem_data *data = (struct mem_data *)hf;
792
793 switch (seektype)
794 {
795 case SEEK_SET:
796 data->pos = dist;
797 break;
798
799 case SEEK_CUR:
800 data->pos += dist;
801 break;
802
803 case SEEK_END:
804 default:
805 ok(0, "seek: not expected type %d\n", seektype);
806 return -1;
807 }
808
809 if (data->pos < 0) data->pos = 0;
810 if (data->pos > data->size) data->pos = data->size;
811
812 /*mem_seek(%p,%d,%d) => %u\n", hf, dist, seektype, data->pos);*/
813 return data->pos;
814}
#define SEEK_END
Definition: cabinet.c:29
#define SEEK_SET
Definition: jmemansi.c:26
#define SEEK_CUR
Definition: util.h:63

Referenced by test_FDICopy().

◆ fdi_mem_write()

static UINT CDECL fdi_mem_write ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 770 of file fdi.c.

771{
772 static const char expected[] = "Hello World!";
773
774 trace("mem_write(%#Ix,%p,%u)\n", hf, pv, cb);
775
776 ok(hf == 0x12345678, "expected 0x12345678, got %#Ix\n", hf);
777 ok(cb == 12, "expected 12, got %u\n", cb);
778 ok(!memcmp(pv, expected, 12), "expected %s, got %s\n", expected, (const char *)pv);
779
780 return cb;
781}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112

Referenced by test_FDICopy().

◆ fdi_open()

static INT_PTR CDECL fdi_open ( char pszFile,
int  oflag,
int  pmode 
)
static

Definition at line 142 of file fdi.c.

143{
146 OPEN_EXISTING, 0, NULL );
148 return 0;
149 return (INT_PTR) handle;
150}

Referenced by test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_open_static()

static INT_PTR CDECL fdi_open_static ( char pszFile,
int  oflag,
int  pmode 
)
static

Definition at line 185 of file fdi.c.

186{
187 ok(0, "FDIIsCabinet shouldn't call pfnopen\n");
188 return 1;
189}

Referenced by test_FDIIsCabinet().

◆ fdi_read()

static UINT CDECL fdi_read ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 152 of file fdi.c.

153{
154 HANDLE handle = (HANDLE) hf;
155 DWORD dwRead;
156 if (ReadFile(handle, pv, cb, &dwRead, NULL))
157 return dwRead;
158 return 0;
159}

Referenced by fdi_read_static(), test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_read_static()

static UINT CDECL fdi_read_static ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 191 of file fdi.c.

192{
193 ok(hf == 0, "unexpected hf %Ix\n", hf);
194 return fdi_read(static_fdi_handle, pv, cb);
195}
static INT_PTR static_fdi_handle
Definition: fdi.c:183
static UINT CDECL fdi_read(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:152

Referenced by test_FDIIsCabinet().

◆ fdi_seek()

static LONG CDECL fdi_seek ( INT_PTR  hf,
LONG  dist,
int  seektype 
)
static

Definition at line 176 of file fdi.c.

177{
178 HANDLE handle = (HANDLE) hf;
179 return SetFilePointer(handle, dist, NULL, seektype);
180}

Referenced by fdi_seek_static(), test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_seek_static()

static LONG CDECL fdi_seek_static ( INT_PTR  hf,
LONG  dist,
int  seektype 
)
static

Definition at line 209 of file fdi.c.

210{
211 ok(hf == 0, "unexpected hf %Ix\n", hf);
212 return fdi_seek(static_fdi_handle, dist, seektype);
213}
static LONG CDECL fdi_seek(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:176

Referenced by test_FDIIsCabinet().

◆ fdi_write()

static UINT CDECL fdi_write ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 161 of file fdi.c.

162{
163 HANDLE handle = (HANDLE) hf;
164 DWORD dwWritten;
165 if (WriteFile(handle, pv, cb, &dwWritten, NULL))
166 return dwWritten;
167 return 0;
168}

Referenced by test_FDICopy(), test_FDICreate(), test_FDIDestroy(), and test_FDIIsCabinet().

◆ fdi_write_static()

static UINT CDECL fdi_write_static ( INT_PTR  hf,
void pv,
UINT  cb 
)
static

Definition at line 197 of file fdi.c.

198{
199 ok(0, "FDIIsCabinet shouldn't call pfnwrite\n");
200 return 0;
201}

Referenced by test_FDIIsCabinet().

◆ file_placed()

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

Definition at line 452 of file fdi.c.

454{
455 return 0;
456}

Referenced by create_cab_file(), and test_FDICopy().

◆ get_next_cabinet()

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

Definition at line 442 of file fdi.c.

443{
444 return TRUE;
445}
#define TRUE
Definition: types.h:120

Referenced by add_file(), create_cab_file(), and test_FDICopy().

◆ 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 552 of file fdi.c.

554{
558 DWORD attrs;
559 BOOL res;
560
563
564 ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
565
567 ok(res, "Expected GetFileInformationByHandle to succeed\n");
568
570 FileTimeToDosDateTime(&filetime, pdate, ptime);
571
572 attrs = GetFileAttributesA(pszName);
573 ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
574 /* fixme: should convert attrs to *pattribs, make sure
575 * have a test that catches the fact that we don't?
576 */
577
578 return (INT_PTR)handle;
579}
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
Definition: fileinfo.c:458
BOOL WINAPI FileTimeToLocalFileTime(IN CONST FILETIME *lpFileTime, OUT LPFILETIME lpLocalFileTime)
Definition: time.c:221
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

Referenced by add_file().

◆ get_temp_file()

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

Definition at line 533 of file fdi.c.

534{
535 LPSTR tempname;
536
537 tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
538 GetTempFileNameA(".", "xx", 0, tempname);
539
540 if (tempname && (strlen(tempname) < (unsigned)cbTempName))
541 {
542 lstrcpyA(pszTempName, tempname);
543 HeapFree(GetProcessHeap(), 0, tempname);
544 return TRUE;
545 }
546
547 HeapFree(GetProcessHeap(), 0, tempname);
548
549 return FALSE;
550}
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
char * LPSTR
Definition: xmlstorage.h:182

Referenced by create_cab_file(), and test_FDICopy().

◆ mem_alloc()

static void *CDECL mem_alloc ( ULONG  cb)
static

Definition at line 432 of file fdi.c.

433{
434 return HeapAlloc(GetProcessHeap(), 0, cb);
435}

◆ mem_free()

static void CDECL mem_free ( void memory)
static

Definition at line 437 of file fdi.c.

438{
440}

◆ progress()

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

Definition at line 447 of file fdi.c.

448{
449 return 0;
450}

◆ set_cab_parameters()

static void set_cab_parameters ( PCCAB  pCabParams)
static

Definition at line 595 of file fdi.c.

596{
597 ZeroMemory(pCabParams, sizeof(CCAB));
598
599 pCabParams->cb = MEDIA_SIZE;
600 pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
601 pCabParams->setID = 0xbeef;
602 lstrcpyA(pCabParams->szCabPath, CURR_DIR);
603 lstrcatA(pCabParams->szCabPath, "\\");
604 lstrcpyA(pCabParams->szCab, "extract.cab");
605}
#define ZeroMemory
Definition: minwinbase.h:31
#define MEDIA_SIZE
Definition: fdi.c:31
#define FOLDER_THRESHOLD
Definition: fdi.c:32
ULONG cbFolderThresh
Definition: fci.h:146
USHORT setID
Definition: fci.h:157
char szCabPath[CB_MAX_CAB_PATH]
Definition: fci.h:161
ULONG cb
Definition: fci.h:145
char szCab[CB_MAX_CABINET_NAME]
Definition: fci.h:160

Referenced by create_cab_file(), and test_FDICopy().

◆ START_TEST()

START_TEST ( fdi  )

Definition at line 938 of file fdi.c.

939{
940 int len;
941
943 if (len && (CURR_DIR[len - 1] == '\\'))
944 CURR_DIR[len - 1] = 0;
945
949 test_FDICopy();
950}
DWORD WINAPI GetCurrentDirectoryA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2146
GLenum GLsizei len
Definition: glext.h:6722
static void test_FDIDestroy(void)
Definition: fdi.c:372
static void test_FDICopy(void)
Definition: fdi.c:850
static void test_FDIIsCabinet(void)
Definition: fdi.c:638
static void test_FDICreate(void)
Definition: fdi.c:215

◆ test_FDICopy()

static void test_FDICopy ( void  )
static

Definition at line 850 of file fdi.c.

851{
852 CCAB cabParams;
853 HFDI hfdi;
854 HFCI hfci;
855 ERF erf;
856 BOOL ret;
857 char name[] = "extract.cab";
858 char path[MAX_PATH + 1];
859 char memory_block[] = "memory\\block";
860 char memory[] = "memory\\";
861 char block[] = "block";
863 INT_PTR fd;
864
865 set_cab_parameters(&cabParams);
866
869 fci_delete, get_temp_file, &cabParams, NULL);
870
872 ok(ret, "Failed to flush the cabinet\n");
873
874 FCIDestroy(hfci);
875
877
878 /* path doesn't have a trailing backslash */
879 if (lstrlenA(path) > 2)
880 {
883 cpuUNKNOWN, &erf);
884
885 SetLastError(0xdeadbeef);
886 ret = FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0);
887 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
889 "Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
890
891 FDIDestroy(hfdi);
892 }
893 else
894 skip("Running on a root drive directory.\n");
895
896 lstrcatA(path, "\\");
897
900 cpuUNKNOWN, &erf);
901
902 /* cabinet with no files or folders */
903 SetLastError(0xdeadbeef);
904 ret = FDICopy(hfdi, name, path, 0, CopyProgress, NULL, 0);
905 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
906 ok(GetLastError() == 0, "Expected 0f, got %ld\n", GetLastError());
907
908 FDIDestroy(hfdi);
909
911
912 /* test extracting from a memory block */
915 ok(hfdi != NULL, "FDICreate error %d\n", erf.erfOper);
916
917 fd = fdi_mem_open(memory_block, _O_BINARY, _S_IREAD | _S_IWRITE);
918 ok(fd != -1, "fdi_open failed\n");
919
920 memset(&info, 0, sizeof(info));
921 ret = FDIIsCabinet(hfdi, fd, &info);
922 ok(ret, "FDIIsCabinet error %d\n", erf.erfOper);
923 ok(info.cbCabinet == 0x59, "expected 0x59, got %#lx\n", info.cbCabinet);
924 ok(info.cFiles == 1, "expected 1, got %d\n", info.cFiles);
925 ok(info.cFolders == 1, "expected 1, got %d\n", info.cFolders);
926 ok(info.setID == 0x1225, "expected 0x1225, got %#x\n", info.setID);
927 ok(info.iCabinet == 0x2013, "expected 0x2013, got %#x\n", info.iCabinet);
928
930
931 ret = FDICopy(hfdi, block, memory, 0, fdi_mem_notify, NULL, 0);
932 ok(ret, "FDICopy error %d\n", erf.erfOper);
933
934 FDIDestroy(hfdi);
935}
#define skip(...)
Definition: atltest.h:64
HFDI __cdecl FDICreate(PFNALLOC pfnalloc, PFNFREE pfnfree, PFNOPEN pfnopen, PFNREAD pfnread, PFNWRITE pfnwrite, PFNCLOSE pfnclose, PFNSEEK pfnseek, int cpuType, PERF perf)
Definition: fdi.c:412
BOOL __cdecl FDIIsCabinet(HFDI hfdi, INT_PTR hf, PFDICABINETINFO pfdici)
Definition: fdi.c:696
BOOL __cdecl FDICopy(HFDI hfdi, char *pszCabinet, char *pszCabPath, int flags, PFNFDINOTIFY pfnfdin, PFNFDIDECRYPT pfnfdid, void *pvUser)
Definition: fdi.c:2431
BOOL __cdecl FDIDestroy(HFDI hfdi)
Definition: fdi.c:2831
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define cpuUNKNOWN
Definition: fdi.h:269
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
static UINT CDECL fdi_mem_read(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:755
static INT_PTR CDECL fdi_mem_notify(FDINOTIFICATIONTYPE fdint, FDINOTIFICATION *info)
Definition: fdi.c:816
static INT_PTR CDECL fdi_mem_open(char *name, int oflag, int pmode)
Definition: fdi.c:735
static int CDECL fdi_close(INT_PTR hf)
Definition: fdi.c:170
static int CDECL fdi_mem_close(INT_PTR hf)
Definition: fdi.c:783
static void CDECL fdi_free(void *pv)
Definition: fdi.c:137
static UINT CDECL fdi_write(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:161
static UINT CDECL fdi_mem_write(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:770
static void *CDECL fdi_alloc(ULONG cb)
Definition: fdi.c:127
static INT_PTR CDECL fdi_open(char *pszFile, int oflag, int pmode)
Definition: fdi.c:142
static INT_PTR __cdecl CopyProgress(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
Definition: fdi.c:730
static LONG CDECL fdi_mem_seek(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:789
static int fd
Definition: io.c:51
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static unsigned int block
Definition: xmlmemory.c:101

Referenced by START_TEST().

◆ test_FDICreate()

static void test_FDICreate ( void  )
static

Definition at line 215 of file fdi.c.

216{
217 HFDI hfdi;
218 ERF erf;
219
220 /* native crashes if pfnalloc is NULL */
221
222 /* FDICreate does not crash with a NULL pfnfree,
223 * but FDIDestroy will crash when it tries to access it.
224 */
225 if (0)
226 {
227 SetLastError(0xdeadbeef);
228 erf.erfOper = 0x1abe11ed;
229 erf.erfType = 0x5eed1e55;
230 erf.fError = 0x1ead1e55;
233 cpuUNKNOWN, &erf);
234 ok(hfdi != NULL, "Expected non-NULL context\n");
235 ok(GetLastError() == 0xdeadbeef,
236 "Expected 0xdeadbeef, got %ld\n", GetLastError());
237 ok(erf.erfOper == 0x1abe11ed, "Expected 0x1abe11ed, got %d\n", erf.erfOper);
238 ok(erf.erfType == 0x5eed1e55, "Expected 0x5eed1e55, got %d\n", erf.erfType);
239 ok(erf.fError == 0x1ead1e55, "Expected 0x1ead1e55, got %d\n", erf.fError);
240
241 FDIDestroy(hfdi);
242 }
243
244 SetLastError(0xdeadbeef);
245 erf.erfOper = 0x1abe11ed;
246 erf.erfType = 0x5eed1e55;
247 erf.fError = 0x1ead1e55;
250 cpuUNKNOWN, &erf);
251 ok(hfdi != NULL, "Expected non-NULL context\n");
252 ok(GetLastError() == 0xdeadbeef,
253 "Expected 0xdeadbeef, got %ld\n", GetLastError());
254 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
255 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
256 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
257
258 FDIDestroy(hfdi);
259
260 SetLastError(0xdeadbeef);
261 erf.erfOper = 0x1abe11ed;
262 erf.erfType = 0x5eed1e55;
263 erf.fError = 0x1ead1e55;
266 cpuUNKNOWN, &erf);
267 ok(hfdi != NULL, "Expected non-NULL context\n");
268 ok(GetLastError() == 0xdeadbeef,
269 "Expected 0xdeadbeef, got %ld\n", GetLastError());
270 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
271 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
272 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
273
274 FDIDestroy(hfdi);
275
276 SetLastError(0xdeadbeef);
277 erf.erfOper = 0x1abe11ed;
278 erf.erfType = 0x5eed1e55;
279 erf.fError = 0x1ead1e55;
282 cpuUNKNOWN, &erf);
283 ok(hfdi != NULL, "Expected non-NULL context\n");
284 ok(GetLastError() == 0xdeadbeef,
285 "Expected 0xdeadbeef, got %ld\n", GetLastError());
286 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
287 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
288 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
289
290 FDIDestroy(hfdi);
291
292 SetLastError(0xdeadbeef);
293 erf.erfOper = 0x1abe11ed;
294 erf.erfType = 0x5eed1e55;
295 erf.fError = 0x1ead1e55;
298 cpuUNKNOWN, &erf);
299 ok(hfdi != NULL, "Expected non-NULL context\n");
300 ok(GetLastError() == 0xdeadbeef,
301 "Expected 0xdeadbeef, got %ld\n", GetLastError());
302 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
303 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
304 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
305
306 FDIDestroy(hfdi);
307
308 SetLastError(0xdeadbeef);
309 erf.erfOper = 0x1abe11ed;
310 erf.erfType = 0x5eed1e55;
311 erf.fError = 0x1ead1e55;
314 cpuUNKNOWN, &erf);
315 ok(hfdi != NULL, "Expected non-NULL context\n");
316 ok(GetLastError() == 0xdeadbeef,
317 "Expected 0xdeadbeef, got %ld\n", GetLastError());
318 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
319 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
320 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
321
322 FDIDestroy(hfdi);
323
324 SetLastError(0xdeadbeef);
325 erf.erfOper = 0x1abe11ed;
326 erf.erfType = 0x5eed1e55;
327 erf.fError = 0x1ead1e55;
331 /* XP sets hfdi to a non-NULL value, but Vista sets it to NULL! */
332 ok(GetLastError() == 0xdeadbeef,
333 "Expected 0xdeadbeef, got %ld\n", GetLastError());
334 /* NULL is passed to FDICreate instead of &erf, so don't retest the erf member values. */
335
336 FDIDestroy(hfdi);
337
338 /* bad cpu type */
339 SetLastError(0xdeadbeef);
340 erf.erfOper = 0x1abe11ed;
341 erf.erfType = 0x5eed1e55;
342 erf.fError = 0x1ead1e55;
345 0xcafebabe, &erf);
346 ok(hfdi != NULL, "Expected non-NULL context\n");
347 ok(GetLastError() == 0xdeadbeef,
348 "Expected 0xdeadbeef, got %ld\n", GetLastError());
349 ok((erf.erfOper == 0x1abe11ed || erf.erfOper == 0 /* Vista */), "Expected 0x1abe11ed or 0, got %d\n", erf.erfOper);
350 ok((erf.erfType == 0x5eed1e55 || erf.erfType == 0 /* Vista */), "Expected 0x5eed1e55 or 0, got %d\n", erf.erfType);
351 ok((erf.fError == 0x1ead1e55 || erf.fError == 0 /* Vista */), "Expected 0x1ead1e55 or 0, got %d\n", erf.fError);
352
353 FDIDestroy(hfdi);
354
355 /* pfnalloc fails */
356 SetLastError(0xdeadbeef);
357 erf.erfOper = 0x1abe11ed;
358 erf.erfType = 0x5eed1e55;
359 erf.fError = 0x1ead1e55;
362 cpuUNKNOWN, &erf);
363 ok(hfdi == NULL, "Expected NULL context, got %p\n", hfdi);
364 ok(erf.erfOper == FDIERROR_ALLOC_FAIL,
365 "Expected FDIERROR_ALLOC_FAIL, got %d\n", erf.erfOper);
366 ok(erf.fError == TRUE, "Expected TRUE, got %d\n", erf.fError);
367 ok(GetLastError() == 0xdeadbeef,
368 "Expected 0xdeadbeef, got %ld\n", GetLastError());
369 ok(erf.erfType == 0, "Expected 0, got %d\n", erf.erfType);
370}
@ FDIERROR_ALLOC_FAIL
Definition: fdi.h:120
static void *CDECL fdi_alloc_bad(ULONG cb)
Definition: fdi.c:132

Referenced by START_TEST().

◆ test_FDIDestroy()

static void test_FDIDestroy ( void  )
static

Definition at line 372 of file fdi.c.

373{
374 HFDI hfdi;
375 ERF erf;
376 BOOL ret;
377
378 /* native crashes if hfdi is NULL or invalid */
379
382 cpuUNKNOWN, &erf);
383 ok(hfdi != NULL, "Expected non-NULL context\n");
384
385 /* successfully destroy hfdi */
386 ret = FDIDestroy(hfdi);
387 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
388
389 /* native crashes if you try to destroy hfdi twice */
390 if (0)
391 {
392 /* try to destroy hfdi again */
393 ret = FDIDestroy(hfdi);
394 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
395 }
396}

Referenced by START_TEST().

◆ test_FDIIsCabinet()

static void test_FDIIsCabinet ( void  )
static

Definition at line 638 of file fdi.c.

639{
640 ERF erf;
641 BOOL ret;
642 HFDI hfdi;
643 INT_PTR fd;
644 FDICABINETINFO cabinfo;
645 char temp[] = "temp.txt";
646 char extract[] = "extract.cab";
647
650
653 cpuUNKNOWN, &erf);
654 ok(hfdi != NULL, "Expected non-NULL context\n");
655
656 /* native crashes if hfdi or cabinfo are NULL or invalid */
657
658 /* invalid file handle */
659 ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
660 SetLastError(0xdeadbeef);
661 ret = FDIIsCabinet(hfdi, -1, &cabinfo);
662 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
664 "Expected ERROR_INVALID_HANDLE, got %ld\n", GetLastError());
665 ok(cabinfo.cbCabinet == 0, "Expected 0, got %ld\n", cabinfo.cbCabinet);
666 ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles);
667 ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders);
668 ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
669 ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID);
670
671 createTestFile("temp.txt");
672 fd = fdi_open(temp, 0, 0);
673
674 /* file handle doesn't point to a cabinet */
675 ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
676 SetLastError(0xdeadbeef);
677 ret = FDIIsCabinet(hfdi, fd, &cabinfo);
678 ok(ret == FALSE, "Expected FALSE, got %d\n", ret);
679 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
680 ok(cabinfo.cbCabinet == 0, "Expected 0, got %ld\n", cabinfo.cbCabinet);
681 ok(cabinfo.cFiles == 0, "Expected 0, got %d\n", cabinfo.cFiles);
682 ok(cabinfo.cFolders == 0, "Expected 0, got %d\n", cabinfo.cFolders);
683 ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
684 ok(cabinfo.setID == 0, "Expected 0, got %d\n", cabinfo.setID);
685
686 fdi_close(fd);
687 DeleteFileA("temp.txt");
688
689 /* try a real cab */
690 fd = fdi_open(extract, 0, 0);
691 ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
692 SetLastError(0xdeadbeef);
693 ret = FDIIsCabinet(hfdi, fd, &cabinfo);
694 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
695 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
696 ok(cabinfo.cFiles == 4, "Expected 4, got %d\n", cabinfo.cFiles);
697 ok(cabinfo.cFolders == 1, "Expected 1, got %d\n", cabinfo.cFolders);
698 ok(cabinfo.setID == 0xbeef, "Expected 0xbeef, got %d\n", cabinfo.setID);
699 ok(cabinfo.cbCabinet == 182, "Expected 182, got %ld\n", cabinfo.cbCabinet);
700 ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
701
702 fdi_close(fd);
703 FDIDestroy(hfdi);
704
707 cpuUNKNOWN, &erf);
708 ok(hfdi != NULL, "Expected non-NULL context\n");
709
710 /* FDIIsCabinet accepts hf == 0 even though it's not a valid result of pfnopen */
712 ZeroMemory(&cabinfo, sizeof(FDICABINETINFO));
713 SetLastError(0xdeadbeef);
714 ret = FDIIsCabinet(hfdi, 0, &cabinfo);
715 ok(ret == TRUE, "Expected TRUE, got %d\n", ret);
716 ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %ld\n", GetLastError());
717 ok(cabinfo.cFiles == 4, "Expected 4, got %d\n", cabinfo.cFiles);
718 ok(cabinfo.cFolders == 1, "Expected 1, got %d\n", cabinfo.cFolders);
719 ok(cabinfo.setID == 0xbeef, "Expected 0xbeef, got %d\n", cabinfo.setID);
720 ok(cabinfo.cbCabinet == 182, "Expected 182, got %ld\n", cabinfo.cbCabinet);
721 ok(cabinfo.iCabinet == 0, "Expected 0, got %d\n", cabinfo.iCabinet);
722
724 FDIDestroy(hfdi);
725
727}
static void extract(LPCWSTR cabfile, LPWSTR destdir)
Definition: extrac32.c:99
static int CDECL fdi_close_static(INT_PTR hf)
Definition: fdi.c:203
static INT_PTR CDECL fdi_open_static(char *pszFile, int oflag, int pmode)
Definition: fdi.c:185
static void delete_test_files(void)
Definition: fdi.c:419
static LONG CDECL fdi_seek_static(INT_PTR hf, LONG dist, int seektype)
Definition: fdi.c:209
static void create_test_files(void)
Definition: fdi.c:410
static void create_cab_file(void)
Definition: fdi.c:607
static UINT CDECL fdi_read_static(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:191
static UINT CDECL fdi_write_static(INT_PTR hf, void *pv, UINT cb)
Definition: fdi.c:197
static calc_node_t temp
Definition: rpn_ieee.c:38
USHORT setID
Definition: fdi.h:149
USHORT iCabinet
Definition: fdi.h:150
USHORT cFiles
Definition: fdi.h:148
USHORT cFolders
Definition: fdi.h:147
LONG cbCabinet
Definition: fdi.h:146

Referenced by START_TEST().

Variable Documentation

◆ ab

UCHAR ab[sizeof("Hello World!") -1]

Definition at line 106 of file fdi.c.

Referenced by QuickLaunchBar::AddButton(), TaskBar::EnumWndProc(), OnCreate(), and TestCommandLine().

◆ 

const struct { ... } cab_data
Initial value:
=
{
{ {'M','S','C','F'}, 0, 0x59, 0, sizeof(struct CFHEADER) + sizeof(struct CFFOLDER), 0, 3,1, 1, 1, 0, 0x1225, 0x2013 },
{ sizeof(struct CFHEADER) + sizeof(struct CFFOLDER) + sizeof(struct CFFILE) + sizeof("file.dat"), 1, tcompTYPE_NONE },
{ sizeof("Hello World!")-1, 0, 0x1234, 0x1225, 0x2013, 0xa114 },
{ 'f','i','l','e','.','d','a','t',0 },
{ 0, sizeof("Hello World!")-1, sizeof("Hello World!")-1 },
{ 'H','e','l','l','o',' ','W','o','r','l','d','!' }
}
#define tcompTYPE_NONE
Definition: fci.h:64
Definition: fci.c:89
Definition: fci.c:82
Definition: fci.c:65
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by fdi_mem_open().

◆ CURR_DIR

CHAR CURR_DIR[MAX_PATH]
static

Definition at line 34 of file fdi.c.

Referenced by add_file(), set_cab_parameters(), START_TEST(), and test_FDICopy().

◆ data

Definition at line 105 of file fdi.c.

◆ file

Definition at line 103 of file fdi.c.

◆ folder

Definition at line 102 of file fdi.c.

◆ header

Definition at line 101 of file fdi.c.

◆ static_fdi_handle

INT_PTR static_fdi_handle
static

Definition at line 183 of file fdi.c.

Referenced by fdi_read_static(), fdi_seek_static(), and test_FDIIsCabinet().

◆ szName

UCHAR szName[sizeof("file.dat")]

Definition at line 104 of file fdi.c.