ReactOS  0.4.12-dev-396-g37af787
iowin32.c File Reference
#include <stdlib.h>
#include "zlib.h"
#include "ioapi.h"
#include "iowin32.h"
Include dependency graph for iowin32.c:

Go to the source code of this file.

Classes

struct  WIN32FILE_IOWIN
 

Macros

#define INVALID_HANDLE_VALUE   (0xFFFFFFFF)
 
#define INVALID_SET_FILE_POINTER   ((DWORD)-1)
 

Functions

voidpf ZCALLBACK win32_open_file_func OF ((voidpf opaque, const char *filename, int mode))
 
uLong ZCALLBACK win32_read_file_func OF ((voidpf opaque, voidpf stream, void *buf, uLong size))
 
uLong ZCALLBACK win32_write_file_func OF ((voidpf opaque, voidpf stream, const void *buf, uLong size))
 
ZPOS64_T ZCALLBACK win32_tell64_file_func OF ((voidpf opaque, voidpf stream))
 
long ZCALLBACK win32_seek64_file_func OF ((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin))
 
static void win32_translate_open_mode (int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
 
static voidpf win32_build_iowin (HANDLE hFile)
 
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque, const void *filename, int mode)
 
voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque, const void *filename, int mode)
 
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque, const void *filename, int mode)
 
voidpf ZCALLBACK win32_open_file_func (voidpf opaque, const char *filename, int mode)
 
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void *buf, uLong size)
 
uLong ZCALLBACK win32_write_file_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
 
static BOOL MySetFilePointerEx (HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
 
long ZCALLBACK win32_tell_file_func (voidpf opaque, voidpf stream)
 
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream)
 
long ZCALLBACK win32_seek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
 
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
 
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
 
int ZCALLBACK win32_error_file_func (voidpf opaque, voidpf stream)
 
void fill_win32_filefunc (zlib_filefunc_def *pzlib_filefunc_def)
 
void fill_win32_filefunc64 (zlib_filefunc64_def *pzlib_filefunc_def)
 
void fill_win32_filefunc64A (zlib_filefunc64_def *pzlib_filefunc_def)
 
void fill_win32_filefunc64W (zlib_filefunc64_def *pzlib_filefunc_def)
 

Macro Definition Documentation

◆ INVALID_HANDLE_VALUE

#define INVALID_HANDLE_VALUE   (0xFFFFFFFF)

Definition at line 21 of file iowin32.c.

◆ INVALID_SET_FILE_POINTER

#define INVALID_SET_FILE_POINTER   ((DWORD)-1)

Definition at line 25 of file iowin32.c.

Function Documentation

◆ fill_win32_filefunc()

void fill_win32_filefunc ( zlib_filefunc_def pzlib_filefunc_def)

Definition at line 414 of file iowin32.c.

415 {
416  pzlib_filefunc_def->zopen_file = win32_open_file_func;
417  pzlib_filefunc_def->zread_file = win32_read_file_func;
418  pzlib_filefunc_def->zwrite_file = win32_write_file_func;
419  pzlib_filefunc_def->ztell_file = win32_tell_file_func;
420  pzlib_filefunc_def->zseek_file = win32_seek_file_func;
421  pzlib_filefunc_def->zclose_file = win32_close_file_func;
422  pzlib_filefunc_def->zerror_file = win32_error_file_func;
423  pzlib_filefunc_def->opaque = NULL;
424 }
testerror_file_func zerror_file
Definition: ioapi.h:154
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition: iowin32.c:220
write_file_func zwrite_file
Definition: ioapi.h:150
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char *filename, int mode)
Definition: iowin32.c:169
smooth NULL
Definition: ftsmooth.c:416
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:386
read_file_func zread_file
Definition: ioapi.h:149
seek_file_func zseek_file
Definition: ioapi.h:152
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:261
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin)
Definition: iowin32.c:309
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:404
tell_file_func ztell_file
Definition: ioapi.h:151
close_file_func zclose_file
Definition: ioapi.h:153
open_file_func zopen_file
Definition: ioapi.h:148
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition: iowin32.c:198

◆ fill_win32_filefunc64()

void fill_win32_filefunc64 ( zlib_filefunc64_def pzlib_filefunc_def)

Definition at line 426 of file iowin32.c.

427 {
428  pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
429  pzlib_filefunc_def->zread_file = win32_read_file_func;
430  pzlib_filefunc_def->zwrite_file = win32_write_file_func;
431  pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
432  pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
433  pzlib_filefunc_def->zclose_file = win32_close_file_func;
434  pzlib_filefunc_def->zerror_file = win32_error_file_func;
435  pzlib_filefunc_def->opaque = NULL;
436 }
testerror_file_func zerror_file
Definition: ioapi.h:170
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition: iowin32.c:220
write_file_func zwrite_file
Definition: ioapi.h:166
smooth NULL
Definition: ftsmooth.c:416
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void *filename, int mode)
Definition: iowin32.c:96
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:386
close_file_func zclose_file
Definition: ioapi.h:169
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:284
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
Definition: iowin32.c:347
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:404
read_file_func zread_file
Definition: ioapi.h:165
open64_file_func zopen64_file
Definition: ioapi.h:164
seek64_file_func zseek64_file
Definition: ioapi.h:168
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition: iowin32.c:198
tell64_file_func ztell64_file
Definition: ioapi.h:167

◆ fill_win32_filefunc64A()

void fill_win32_filefunc64A ( zlib_filefunc64_def pzlib_filefunc_def)

Definition at line 439 of file iowin32.c.

440 {
441  pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
442  pzlib_filefunc_def->zread_file = win32_read_file_func;
443  pzlib_filefunc_def->zwrite_file = win32_write_file_func;
444  pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
445  pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
446  pzlib_filefunc_def->zclose_file = win32_close_file_func;
447  pzlib_filefunc_def->zerror_file = win32_error_file_func;
448  pzlib_filefunc_def->opaque = NULL;
449 }
testerror_file_func zerror_file
Definition: ioapi.h:170
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition: iowin32.c:220
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void *filename, int mode)
Definition: iowin32.c:125
write_file_func zwrite_file
Definition: ioapi.h:166
smooth NULL
Definition: ftsmooth.c:416
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:386
close_file_func zclose_file
Definition: ioapi.h:169
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:284
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
Definition: iowin32.c:347
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:404
read_file_func zread_file
Definition: ioapi.h:165
open64_file_func zopen64_file
Definition: ioapi.h:164
seek64_file_func zseek64_file
Definition: ioapi.h:168
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition: iowin32.c:198
tell64_file_func ztell64_file
Definition: ioapi.h:167

◆ fill_win32_filefunc64W()

void fill_win32_filefunc64W ( zlib_filefunc64_def pzlib_filefunc_def)

Definition at line 452 of file iowin32.c.

453 {
454  pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
455  pzlib_filefunc_def->zread_file = win32_read_file_func;
456  pzlib_filefunc_def->zwrite_file = win32_write_file_func;
457  pzlib_filefunc_def->ztell64_file = win32_tell64_file_func;
458  pzlib_filefunc_def->zseek64_file = win32_seek64_file_func;
459  pzlib_filefunc_def->zclose_file = win32_close_file_func;
460  pzlib_filefunc_def->zerror_file = win32_error_file_func;
461  pzlib_filefunc_def->opaque = NULL;
462 }
testerror_file_func zerror_file
Definition: ioapi.h:170
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
Definition: iowin32.c:220
write_file_func zwrite_file
Definition: ioapi.h:166
smooth NULL
Definition: ftsmooth.c:416
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:386
close_file_func zclose_file
Definition: ioapi.h:169
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:284
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
Definition: iowin32.c:347
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream)
Definition: iowin32.c:404
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void *filename, int mode)
Definition: iowin32.c:149
read_file_func zread_file
Definition: ioapi.h:165
open64_file_func zopen64_file
Definition: ioapi.h:164
seek64_file_func zseek64_file
Definition: ioapi.h:168
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
Definition: iowin32.c:198
tell64_file_func ztell64_file
Definition: ioapi.h:167

Referenced by init_zlib().

◆ MySetFilePointerEx()

static BOOL MySetFilePointerEx ( HANDLE  hFile,
LARGE_INTEGER  pos,
LARGE_INTEGER newPos,
DWORD  dwMoveMethod 
)
static

Definition at line 241 of file iowin32.c.

242 {
243 #ifdef IOWIN32_USING_WINRT_API
244  return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
245 #else
246  LONG lHigh = pos.HighPart;
247  DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod);
248  BOOL fOk = TRUE;
249  if (dwNewPos == 0xFFFFFFFF)
250  if (GetLastError() != NO_ERROR)
251  fOk = FALSE;
252  if ((newPos != NULL) && (fOk))
253  {
254  newPos->LowPart = dwNewPos;
255  newPos->HighPart = lHigh;
256  }
257  return fOk;
258 #endif
259 }
BOOL WINAPI SetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
Definition: fileinfo.c:327
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
Definition: fileinfo.c:204
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG LowPart
Definition: typedefs.h:104
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by win32_seek64_file_func(), win32_seek_file_func(), win32_tell64_file_func(), and win32_tell_file_func().

◆ OF() [1/5]

◆ OF() [2/5]

◆ OF() [3/5]

◆ OF() [4/5]

◆ OF() [5/5]

◆ win32_build_iowin()

static voidpf win32_build_iowin ( HANDLE  hFile)
static

Definition at line 77 of file iowin32.c.

78 {
79  voidpf ret=NULL;
80 
81  if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
82  {
83  WIN32FILE_IOWIN w32fiow;
84  w32fiow.hf = hFile;
85  w32fiow.error = 0;
86  ret = malloc(sizeof(WIN32FILE_IOWIN));
87 
88  if (ret==NULL)
90  else
91  *((WIN32FILE_IOWIN*)ret) = w32fiow;
92  }
93  return ret;
94 }
#define CloseHandle
Definition: compat.h:398
#define INVALID_HANDLE_VALUE
Definition: iowin32.c:21
smooth NULL
Definition: ftsmooth.c:416
int ret
_In_ HANDLE hFile
Definition: mswsock.h:90
Byte FAR * voidpf
Definition: zconf.h:413
HANDLE hf
Definition: iowin32.c:46
#define malloc
Definition: debug_ros.c:4

Referenced by win32_open64_file_func(), win32_open64_file_funcA(), win32_open64_file_funcW(), and win32_open_file_func().

◆ win32_close_file_func()

int ZCALLBACK win32_close_file_func ( voidpf  opaque,
voidpf  stream 
)

Definition at line 386 of file iowin32.c.

387 {
388  int ret=-1;
389 
390  if (stream!=NULL)
391  {
392  HANDLE hFile;
393  hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
394  if (hFile != NULL)
395  {
397  ret=0;
398  }
399  free(stream);
400  }
401  return ret;
402 }
#define CloseHandle
Definition: compat.h:398
#define free
Definition: debug_ros.c:5
smooth NULL
Definition: ftsmooth.c:416
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90

Referenced by fill_win32_filefunc(), fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().

◆ win32_error_file_func()

int ZCALLBACK win32_error_file_func ( voidpf  opaque,
voidpf  stream 
)

Definition at line 404 of file iowin32.c.

405 {
406  int ret=-1;
407  if (stream!=NULL)
408  {
409  ret = ((WIN32FILE_IOWIN*)stream) -> error;
410  }
411  return ret;
412 }
#define error(str)
Definition: mkdosfs.c:1605
smooth NULL
Definition: ftsmooth.c:416
int ret
Definition: parse.h:22

Referenced by fill_win32_filefunc(), fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().

◆ win32_open64_file_func()

voidpf ZCALLBACK win32_open64_file_func ( voidpf  opaque,
const void filename,
int  mode 
)

Definition at line 96 of file iowin32.c.

97 {
98  //const char* mode_fopen = NULL;
99  DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
100  HANDLE hFile = NULL;
101 
102  win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
103 
104 #ifdef IOWIN32_USING_WINRT_API
105 #ifdef UNICODE
106  if ((filename!=NULL) && (dwDesiredAccess != 0))
107  hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
108 #else
109  if ((filename!=NULL) && (dwDesiredAccess != 0))
110  {
111  WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
112  MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
113  hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
114  }
115 #endif
116 #else
117  if ((filename!=NULL) && (dwDesiredAccess != 0))
118  hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
119 #endif
120 
121  return win32_build_iowin(hFile);
122 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static const WCHAR filenameW[]
Definition: amstream.c:41
smooth NULL
Definition: ftsmooth.c:416
static voidpf win32_build_iowin(HANDLE hFile)
Definition: iowin32.c:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum mode
Definition: glext.h:6217
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define MultiByteToWideChar
Definition: compat.h:100
static void win32_translate_open_mode(int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
Definition: iowin32.c:51
#define FILENAME_MAX
Definition: stdio.h:64
WINBASEAPI HANDLE WINAPI CreateFile2(LPCWSTR, DWORD, DWORD, DWORD, LPCREATEFILE2_EXTENDED_PARAMETERS)

Referenced by fill_win32_filefunc64().

◆ win32_open64_file_funcA()

voidpf ZCALLBACK win32_open64_file_funcA ( voidpf  opaque,
const void filename,
int  mode 
)

Definition at line 125 of file iowin32.c.

126 {
127  //const char* mode_fopen = NULL;
128  DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
129  HANDLE hFile = NULL;
130 
131  win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
132 
133 #ifdef IOWIN32_USING_WINRT_API
134  if ((filename!=NULL) && (dwDesiredAccess != 0))
135  {
136  WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
137  MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
138  hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
139  }
140 #else
141  if ((filename!=NULL) && (dwDesiredAccess != 0))
142  hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
143 #endif
144 
145  return win32_build_iowin(hFile);
146 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static const WCHAR filenameW[]
Definition: amstream.c:41
smooth NULL
Definition: ftsmooth.c:416
const char * LPCSTR
Definition: xmlstorage.h:183
static voidpf win32_build_iowin(HANDLE hFile)
Definition: iowin32.c:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum mode
Definition: glext.h:6217
_In_ HANDLE hFile
Definition: mswsock.h:90
#define MultiByteToWideChar
Definition: compat.h:100
static void win32_translate_open_mode(int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
Definition: iowin32.c:51
#define FILENAME_MAX
Definition: stdio.h:64
WINBASEAPI HANDLE WINAPI CreateFile2(LPCWSTR, DWORD, DWORD, DWORD, LPCREATEFILE2_EXTENDED_PARAMETERS)
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399

Referenced by fill_win32_filefunc64A().

◆ win32_open64_file_funcW()

voidpf ZCALLBACK win32_open64_file_funcW ( voidpf  opaque,
const void filename,
int  mode 
)

Definition at line 149 of file iowin32.c.

150 {
151  //const char* mode_fopen = NULL;
152  DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
153  HANDLE hFile = NULL;
154 
155  win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
156 
157 #ifdef IOWIN32_USING_WINRT_API
158  if ((filename!=NULL) && (dwDesiredAccess != 0))
159  hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
160 #else
161  if ((filename!=NULL) && (dwDesiredAccess != 0))
162  hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
163 #endif
164 
165  return win32_build_iowin(hFile);
166 }
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
const char * filename
Definition: ioapi.h:135
smooth NULL
Definition: ftsmooth.c:416
static voidpf win32_build_iowin(HANDLE hFile)
Definition: iowin32.c:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum mode
Definition: glext.h:6217
_In_ HANDLE hFile
Definition: mswsock.h:90
static void win32_translate_open_mode(int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
Definition: iowin32.c:51
#define CreateFileW
Definition: compat.h:400
WINBASEAPI HANDLE WINAPI CreateFile2(LPCWSTR, DWORD, DWORD, DWORD, LPCREATEFILE2_EXTENDED_PARAMETERS)

Referenced by fill_win32_filefunc64W().

◆ win32_open_file_func()

voidpf ZCALLBACK win32_open_file_func ( voidpf  opaque,
const char filename,
int  mode 
)

Definition at line 169 of file iowin32.c.

170 {
171  //const char* mode_fopen = NULL;
172  DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
173  HANDLE hFile = NULL;
174 
175  win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes);
176 
177 #ifdef IOWIN32_USING_WINRT_API
178 #ifdef UNICODE
179  if ((filename!=NULL) && (dwDesiredAccess != 0))
180  hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
181 #else
182  if ((filename!=NULL) && (dwDesiredAccess != 0))
183  {
184  WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
185  MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
186  hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
187  }
188 #endif
189 #else
190  if ((filename!=NULL) && (dwDesiredAccess != 0))
191  hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
192 #endif
193 
194  return win32_build_iowin(hFile);
195 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
const char * filename
Definition: ioapi.h:135
static const WCHAR filenameW[]
Definition: amstream.c:41
smooth NULL
Definition: ftsmooth.c:416
static voidpf win32_build_iowin(HANDLE hFile)
Definition: iowin32.c:77
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum mode
Definition: glext.h:6217
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define MultiByteToWideChar
Definition: compat.h:100
static void win32_translate_open_mode(int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
Definition: iowin32.c:51
#define FILENAME_MAX
Definition: stdio.h:64
WINBASEAPI HANDLE WINAPI CreateFile2(LPCWSTR, DWORD, DWORD, DWORD, LPCREATEFILE2_EXTENDED_PARAMETERS)

Referenced by fill_win32_filefunc().

◆ win32_read_file_func()

uLong ZCALLBACK win32_read_file_func ( voidpf  opaque,
voidpf  stream,
void buf,
uLong  size 
)

Definition at line 198 of file iowin32.c.

199 {
200  uLong ret=0;
201  HANDLE hFile = NULL;
202  if (stream!=NULL)
203  hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
204 
205  if (hFile != NULL)
206  {
207  if (!ReadFile(hFile, buf, size, &ret, NULL))
208  {
210  if (dwErr == ERROR_HANDLE_EOF)
211  dwErr = 0;
213  }
214  }
215 
216  return ret;
217 }
#define error(str)
Definition: mkdosfs.c:1605
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
unsigned long uLong
Definition: zconf.h:394
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_HANDLE_EOF
Definition: winerror.h:140
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc(), fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().

◆ win32_seek64_file_func()

long ZCALLBACK win32_seek64_file_func ( voidpf  opaque,
voidpf  stream,
ZPOS64_T  offset,
int  origin 
)

Definition at line 347 of file iowin32.c.

348 {
349  DWORD dwMoveMethod=0xFFFFFFFF;
350  HANDLE hFile = NULL;
351  long ret=-1;
352 
353  if (stream!=NULL)
354  hFile = ((WIN32FILE_IOWIN*)stream)->hf;
355 
356  switch (origin)
357  {
359  dwMoveMethod = FILE_CURRENT;
360  break;
362  dwMoveMethod = FILE_END;
363  break;
365  dwMoveMethod = FILE_BEGIN;
366  break;
367  default: return -1;
368  }
369 
370  if (hFile)
371  {
373  pos.QuadPart = offset;
374  if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
375  {
378  ret = -1;
379  }
380  else
381  ret=0;
382  }
383  return ret;
384 }
#define error(str)
Definition: mkdosfs.c:1605
#define FILE_CURRENT
Definition: winbase.h:113
GLintptr offset
Definition: glext.h:5920
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
#define ZLIB_FILEFUNC_SEEK_CUR
Definition: ioapi.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
#define FILE_END
Definition: winbase.h:114
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_BEGIN
Definition: winbase.h:112
#define ZLIB_FILEFUNC_SEEK_END
Definition: ioapi.h:113
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
Definition: iowin32.c:241
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().

◆ win32_seek_file_func()

long ZCALLBACK win32_seek_file_func ( voidpf  opaque,
voidpf  stream,
uLong  offset,
int  origin 
)

Definition at line 309 of file iowin32.c.

310 {
311  DWORD dwMoveMethod=0xFFFFFFFF;
312  HANDLE hFile = NULL;
313 
314  long ret=-1;
315  if (stream!=NULL)
316  hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
317  switch (origin)
318  {
320  dwMoveMethod = FILE_CURRENT;
321  break;
323  dwMoveMethod = FILE_END;
324  break;
326  dwMoveMethod = FILE_BEGIN;
327  break;
328  default: return -1;
329  }
330 
331  if (hFile != NULL)
332  {
334  pos.QuadPart = offset;
335  if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod))
336  {
339  ret = -1;
340  }
341  else
342  ret=0;
343  }
344  return ret;
345 }
#define error(str)
Definition: mkdosfs.c:1605
#define FILE_CURRENT
Definition: winbase.h:113
GLintptr offset
Definition: glext.h:5920
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
voidpf uLong int origin
Definition: ioapi.h:142
#define ZLIB_FILEFUNC_SEEK_CUR
Definition: ioapi.h:112
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
#define FILE_END
Definition: winbase.h:114
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
#define FILE_BEGIN
Definition: winbase.h:112
#define ZLIB_FILEFUNC_SEEK_END
Definition: ioapi.h:113
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
Definition: iowin32.c:241
#define ZLIB_FILEFUNC_SEEK_SET
Definition: ioapi.h:114
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc().

◆ win32_tell64_file_func()

ZPOS64_T ZCALLBACK win32_tell64_file_func ( voidpf  opaque,
voidpf  stream 
)

Definition at line 284 of file iowin32.c.

285 {
286  ZPOS64_T ret= (ZPOS64_T)-1;
287  HANDLE hFile = NULL;
288  if (stream!=NULL)
289  hFile = ((WIN32FILE_IOWIN*)stream)->hf;
290 
291  if (hFile)
292  {
294  pos.QuadPart = 0;
295 
297  {
300  ret = (ZPOS64_T)-1;
301  }
302  else
303  ret=pos.QuadPart;
304  }
305  return ret;
306 }
#define error(str)
Definition: mkdosfs.c:1605
#define FILE_CURRENT
Definition: winbase.h:113
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned long long int ZPOS64_T
Definition: ioapi.h:100
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
Definition: iowin32.c:241
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().

◆ win32_tell_file_func()

long ZCALLBACK win32_tell_file_func ( voidpf  opaque,
voidpf  stream 
)

Definition at line 261 of file iowin32.c.

262 {
263  long ret=-1;
264  HANDLE hFile = NULL;
265  if (stream!=NULL)
266  hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
267  if (hFile != NULL)
268  {
270  pos.QuadPart = 0;
271 
273  {
276  ret = -1;
277  }
278  else
279  ret=(long)pos.LowPart;
280  }
281  return ret;
282 }
#define error(str)
Definition: mkdosfs.c:1605
#define FILE_CURRENT
Definition: winbase.h:113
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
#define long
Definition: qsort.c:33
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
Definition: iowin32.c:241
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc().

◆ win32_translate_open_mode()

static void win32_translate_open_mode ( int  mode,
DWORD lpdwDesiredAccess,
DWORD lpdwCreationDisposition,
DWORD lpdwShareMode,
DWORD lpdwFlagsAndAttributes 
)
static

Definition at line 51 of file iowin32.c.

56 {
57  *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
58 
60  {
61  *lpdwDesiredAccess = GENERIC_READ;
62  *lpdwCreationDisposition = OPEN_EXISTING;
63  *lpdwShareMode = FILE_SHARE_READ;
64  }
66  {
67  *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
68  *lpdwCreationDisposition = OPEN_EXISTING;
69  }
71  {
72  *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
73  *lpdwCreationDisposition = CREATE_ALWAYS;
74  }
75 }
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER
Definition: ioapi.h:118
#define ZLIB_FILEFUNC_MODE_READ
Definition: ioapi.h:116
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
#define OPEN_EXISTING
Definition: compat.h:426
#define ZLIB_FILEFUNC_MODE_CREATE
Definition: ioapi.h:121
#define ZLIB_FILEFUNC_MODE_EXISTING
Definition: ioapi.h:120
#define GENERIC_READ
Definition: compat.h:124
GLenum mode
Definition: glext.h:6217
#define CREATE_ALWAYS
Definition: disk.h:72

Referenced by win32_open64_file_func(), win32_open64_file_funcA(), win32_open64_file_funcW(), and win32_open_file_func().

◆ win32_write_file_func()

uLong ZCALLBACK win32_write_file_func ( voidpf  opaque,
voidpf  stream,
const void buf,
uLong  size 
)

Definition at line 220 of file iowin32.c.

221 {
222  uLong ret=0;
223  HANDLE hFile = NULL;
224  if (stream!=NULL)
225  hFile = ((WIN32FILE_IOWIN*)stream) -> hf;
226 
227  if (hFile != NULL)
228  {
229  if (!WriteFile(hFile, buf, size, &ret, NULL))
230  {
232  if (dwErr == ERROR_HANDLE_EOF)
233  dwErr = 0;
235  }
236  }
237 
238  return ret;
239 }
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 error(str)
Definition: mkdosfs.c:1605
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
smooth NULL
Definition: ftsmooth.c:416
DWORD dwErr
Definition: service.c:36
unsigned long uLong
Definition: zconf.h:394
GLsizeiptr size
Definition: glext.h:5919
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
Definition: parse.h:22
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_HANDLE_EOF
Definition: winerror.h:140
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29

Referenced by fill_win32_filefunc(), fill_win32_filefunc64(), fill_win32_filefunc64A(), and fill_win32_filefunc64W().