20 #ifndef INVALID_HANDLE_VALUE 21 #define INVALID_HANDLE_VALUE (0xFFFFFFFF) 24 #ifndef INVALID_SET_FILE_POINTER 25 #define INVALID_SET_FILE_POINTER ((DWORD)-1) 29 #if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) 30 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) 31 #define IOWIN32_USING_WINRT_API 1 51 DWORD* lpdwDesiredAccess,
52 DWORD* lpdwCreationDisposition,
54 DWORD* lpdwFlagsAndAttributes)
56 *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
60 *lpdwDesiredAccess = GENERIC_READ;
61 *lpdwCreationDisposition = OPEN_EXISTING;
62 *lpdwShareMode = FILE_SHARE_READ;
66 *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
67 *lpdwCreationDisposition = OPEN_EXISTING;
71 *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ;
72 *lpdwCreationDisposition = CREATE_ALWAYS;
97 const char* mode_fopen = NULL;
98 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
103 #ifdef IOWIN32_USING_WINRT_API 105 if ((filename!=NULL) && (dwDesiredAccess != 0))
106 hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
108 if ((filename!=NULL) && (dwDesiredAccess != 0))
110 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
111 MultiByteToWideChar(CP_ACP,0,(
const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
112 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
116 if ((filename!=NULL) && (dwDesiredAccess != 0))
117 hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
126 const char* mode_fopen = NULL;
127 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
132 #ifdef IOWIN32_USING_WINRT_API 133 if ((filename!=NULL) && (dwDesiredAccess != 0))
135 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
136 MultiByteToWideChar(CP_ACP,0,(
const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
137 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
140 if ((filename!=NULL) && (dwDesiredAccess != 0))
141 hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
150 const char* mode_fopen = NULL;
151 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
156 #ifdef IOWIN32_USING_WINRT_API 157 if ((filename!=NULL) && (dwDesiredAccess != 0))
158 hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL);
160 if ((filename!=NULL) && (dwDesiredAccess != 0))
161 hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
170 const char* mode_fopen = NULL;
171 DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
176 #ifdef IOWIN32_USING_WINRT_API 178 if ((filename!=NULL) && (dwDesiredAccess != 0))
179 hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
181 if ((filename!=NULL) && (dwDesiredAccess != 0))
183 WCHAR filenameW[FILENAME_MAX + 0x200 + 1];
184 MultiByteToWideChar(CP_ACP,0,(
const char*)filename,-1,filenameW,FILENAME_MAX + 0x200);
185 hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL);
189 if ((filename!=NULL) && (dwDesiredAccess != 0))
190 hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL);
206 if (!ReadFile(hFile, buf, size, &ret, NULL))
208 DWORD dwErr = GetLastError();
209 if (dwErr == ERROR_HANDLE_EOF)
228 if (!WriteFile(hFile, buf, size, &ret, NULL))
230 DWORD dwErr = GetLastError();
231 if (dwErr == ERROR_HANDLE_EOF)
240 static BOOL
MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
242 #ifdef IOWIN32_USING_WINRT_API 243 return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
245 LONG lHigh = pos.HighPart;
246 DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT);
248 if (dwNewPos == 0xFFFFFFFF)
249 if (GetLastError() != NO_ERROR)
251 if ((newPos != NULL) && (fOk))
253 newPos->LowPart = dwNewPos;
254 newPos->HighPart = lHigh;
273 DWORD dwErr = GetLastError();
278 ret=(long)pos.LowPart;
297 DWORD dwErr = GetLastError();
310 DWORD dwMoveMethod=0xFFFFFFFF;
319 dwMoveMethod = FILE_CURRENT;
322 dwMoveMethod = FILE_END;
325 dwMoveMethod = FILE_BEGIN;
333 pos.QuadPart = offset;
336 DWORD dwErr = GetLastError();
348 DWORD dwMoveMethod=0xFFFFFFFF;
358 dwMoveMethod = FILE_CURRENT;
361 dwMoveMethod = FILE_END;
364 dwMoveMethod = FILE_BEGIN;
372 pos.QuadPart = offset;
375 DWORD dwErr = GetLastError();
422 pzlib_filefunc_def->
opaque = NULL;
434 pzlib_filefunc_def->
opaque = NULL;
447 pzlib_filefunc_def->
opaque = NULL;
460 pzlib_filefunc_def->
opaque = NULL;
close_file_func zclose_file
close_file_func zclose_file
long win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin)
voidpf win32_open_file_func(voidpf opaque, const char *filename, int mode)
void fill_win32_filefunc64W(zlib_filefunc64_def *pzlib_filefunc_def)
void fill_win32_filefunc64A(zlib_filefunc64_def *pzlib_filefunc_def)
long win32_tell_file_func(voidpf opaque, voidpf stream)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER
read_file_func zread_file
#define ZLIB_FILEFUNC_MODE_READ
void fill_win32_filefunc(zlib_filefunc_def *pzlib_filefunc_def)
voidpf win32_open64_file_funcW(voidpf opaque, const void *filename, int mode)
tell64_file_func ztell64_file
#define INVALID_HANDLE_VALUE
#define ZLIB_FILEFUNC_SEEK_CUR
seek64_file_func zseek64_file
static voidpf win32_build_iowin(HANDLE hFile)
void error(const char *msg)
ZPOS64_T win32_tell64_file_func(voidpf opaque, voidpf stream)
open_file_func zopen_file
#define ZLIB_FILEFUNC_MODE_CREATE
unsigned long long int ZPOS64_T
int win32_error_file_func(voidpf opaque, voidpf stream)
int win32_close_file_func(voidpf opaque, voidpf stream)
#define ZLIB_FILEFUNC_MODE_EXISTING
tell_file_func ztell_file
write_file_func zwrite_file
testerror_file_func zerror_file
testerror_file_func zerror_file
void fill_win32_filefunc64(zlib_filefunc64_def *pzlib_filefunc_def)
long win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)
voidpf win32_open64_file_funcA(voidpf opaque, const void *filename, int mode)
uLong win32_read_file_func(voidpf opaque, voidpf stream, void *buf, uLong size)
write_file_func zwrite_file
static void win32_translate_open_mode(int mode, DWORD *lpdwDesiredAccess, DWORD *lpdwCreationDisposition, DWORD *lpdwShareMode, DWORD *lpdwFlagsAndAttributes)
#define ZLIB_FILEFUNC_SEEK_END
read_file_func zread_file
voidpf win32_open_file_func OF((voidpf opaque, const char *filename, int mode))
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod)
voidpf win32_open64_file_func(voidpf opaque, const void *filename, int mode)
uLong win32_write_file_func(voidpf opaque, voidpf stream, const void *buf, uLong size)
#define ZLIB_FILEFUNC_SEEK_SET
seek_file_func zseek_file
open64_file_func zopen64_file