|
|
@ -25,6 +25,13 @@ |
|
|
|
#define INVALID_SET_FILE_POINTER ((DWORD)-1) |
|
|
|
#define INVALID_SET_FILE_POINTER ((DWORD)-1) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API))) |
|
|
|
|
|
|
|
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) |
|
|
|
|
|
|
|
#define IOWIN32_USING_WINRT_API 1 |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); |
|
|
|
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_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)); |
|
|
|
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); |
|
|
@ -93,8 +100,22 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int |
|
|
|
|
|
|
|
|
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef IOWIN32_USING_WINRT_API |
|
|
|
|
|
|
|
#ifdef UNICODE |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; |
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); |
|
|
|
|
|
|
|
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#else |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return win32_build_iowin(hFile); |
|
|
|
return win32_build_iowin(hFile); |
|
|
|
} |
|
|
|
} |
|
|
@ -108,8 +129,17 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int |
|
|
|
|
|
|
|
|
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef IOWIN32_USING_WINRT_API |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; |
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); |
|
|
|
|
|
|
|
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
hFile = CreateFileA((LPCSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return win32_build_iowin(hFile); |
|
|
|
return win32_build_iowin(hFile); |
|
|
|
} |
|
|
|
} |
|
|
@ -123,8 +153,13 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int |
|
|
|
|
|
|
|
|
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef IOWIN32_USING_WINRT_API |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
hFile = CreateFile2((LPCWSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition,NULL); |
|
|
|
|
|
|
|
#else |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
hFile = CreateFileW((LPCWSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return win32_build_iowin(hFile); |
|
|
|
return win32_build_iowin(hFile); |
|
|
|
} |
|
|
|
} |
|
|
@ -138,8 +173,22 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo |
|
|
|
|
|
|
|
|
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef IOWIN32_USING_WINRT_API |
|
|
|
|
|
|
|
#ifdef UNICODE |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
hFile = CreateFile2((LPCTSTR)filename, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
WCHAR filenameW[FILENAME_MAX + 0x200 + 1]; |
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP,0,(const char*)filename,-1,filenameW,FILENAME_MAX + 0x200); |
|
|
|
|
|
|
|
hFile = CreateFile2(filenameW, dwDesiredAccess, dwShareMode, dwCreationDisposition, NULL); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
#else |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
if ((filename!=NULL) && (dwDesiredAccess != 0)) |
|
|
|
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwFlagsAndAttributes, NULL); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return win32_build_iowin(hFile); |
|
|
|
return win32_build_iowin(hFile); |
|
|
|
} |
|
|
|
} |
|
|
@ -188,6 +237,26 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef IOWIN32_USING_WINRT_API |
|
|
|
|
|
|
|
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
LONG lHigh = pos.HighPart; |
|
|
|
|
|
|
|
DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, FILE_CURRENT); |
|
|
|
|
|
|
|
BOOL fOk = TRUE; |
|
|
|
|
|
|
|
if (dwNewPos == 0xFFFFFFFF) |
|
|
|
|
|
|
|
if (GetLastError() != NO_ERROR) |
|
|
|
|
|
|
|
fOk = FALSE; |
|
|
|
|
|
|
|
if ((newPos != NULL) && (fOk)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
newPos->LowPart = dwNewPos; |
|
|
|
|
|
|
|
newPos->HighPart = lHigh; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return fOk; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) |
|
|
|
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) |
|
|
|
{ |
|
|
|
{ |
|
|
|
long ret=-1; |
|
|
|
long ret=-1; |
|
|
@ -196,15 +265,17 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) |
|
|
|
hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
|
|
|
hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
|
|
|
if (hFile != NULL) |
|
|
|
if (hFile != NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); |
|
|
|
LARGE_INTEGER pos; |
|
|
|
if (dwSet == INVALID_SET_FILE_POINTER) |
|
|
|
pos.QuadPart = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
ret = -1; |
|
|
|
ret = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
ret=(long)dwSet; |
|
|
|
ret=(long)pos.LowPart; |
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -218,17 +289,17 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) |
|
|
|
|
|
|
|
|
|
|
|
if (hFile) |
|
|
|
if (hFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LARGE_INTEGER li; |
|
|
|
LARGE_INTEGER pos; |
|
|
|
li.QuadPart = 0; |
|
|
|
pos.QuadPart = 0; |
|
|
|
li.u.LowPart = SetFilePointer(hFile, li.u.LowPart, &li.u.HighPart, FILE_CURRENT); |
|
|
|
|
|
|
|
if ( (li.LowPart == 0xFFFFFFFF) && (GetLastError() != NO_ERROR)) |
|
|
|
if (!MySetFilePointerEx(hFile, pos, &pos, FILE_CURRENT)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
ret = (ZPOS64_T)-1; |
|
|
|
ret = (ZPOS64_T)-1; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
ret=li.QuadPart; |
|
|
|
ret=pos.QuadPart; |
|
|
|
} |
|
|
|
} |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
@ -258,8 +329,9 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in |
|
|
|
|
|
|
|
|
|
|
|
if (hFile != NULL) |
|
|
|
if (hFile != NULL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); |
|
|
|
LARGE_INTEGER pos; |
|
|
|
if (dwSet == INVALID_SET_FILE_POINTER) |
|
|
|
pos.QuadPart = offset; |
|
|
|
|
|
|
|
if (!MySetFilePointerEx(hFile, pos, NULL, dwMoveMethod)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
@ -296,9 +368,9 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off |
|
|
|
|
|
|
|
|
|
|
|
if (hFile) |
|
|
|
if (hFile) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LARGE_INTEGER* li = (LARGE_INTEGER*)&offset; |
|
|
|
LARGE_INTEGER pos; |
|
|
|
DWORD dwSet = SetFilePointer(hFile, li->u.LowPart, &li->u.HighPart, dwMoveMethod); |
|
|
|
pos.QuadPart = offset; |
|
|
|
if (dwSet == INVALID_SET_FILE_POINTER) |
|
|
|
if (!MySetFilePointerEx(hFile, pos, NULL, FILE_CURRENT)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
DWORD dwErr = GetLastError(); |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|
((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
|
|
|