mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
windows: mingw file type is int
This commit is contained in:
parent
87dd9283e1
commit
591d42ff67
3 changed files with 19 additions and 6 deletions
|
@ -392,8 +392,12 @@ struct lws;
|
|||
#if defined(_WIN32)
|
||||
#if !defined(LWS_WIN32_HANDLE_TYPES)
|
||||
typedef SOCKET lws_sockfd_type;
|
||||
#if defined(__MINGW32__)
|
||||
typedef int lws_filefd_type;
|
||||
#else
|
||||
typedef HANDLE lws_filefd_type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#define lws_pollfd pollfd
|
||||
|
|
|
@ -155,7 +155,11 @@ struct lws_fd_hashtable {
|
|||
#endif
|
||||
|
||||
typedef SOCKET lws_sockfd_type;
|
||||
#if defined(__MINGW32__)
|
||||
typedef int lws_filefd_type;
|
||||
#else
|
||||
typedef HANDLE lws_filefd_type;
|
||||
#endif
|
||||
#define LWS_WIN32_HANDLE_TYPES
|
||||
|
||||
LWS_EXTERN struct lws *
|
||||
|
|
|
@ -58,8 +58,13 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
|
|||
goto bail;
|
||||
|
||||
fop_fd->fops = fops;
|
||||
#if defined(__MINGW32__)
|
||||
/* we use filesystem_priv */
|
||||
fop_fd->fd = (int)(intptr_t)ret;
|
||||
#else
|
||||
fop_fd->fd = ret;
|
||||
fop_fd->filesystem_priv = NULL; /* we don't use it */
|
||||
#endif
|
||||
fop_fd->filesystem_priv = ret;
|
||||
fop_fd->flags = *flags;
|
||||
fop_fd->len = GetFileSize(ret, NULL);
|
||||
if(GetFileSizeEx(ret, &llFileSize))
|
||||
|
@ -76,7 +81,7 @@ bail:
|
|||
int
|
||||
_lws_plat_file_close(lws_fop_fd_t *fop_fd)
|
||||
{
|
||||
HANDLE fd = (*fop_fd)->fd;
|
||||
HANDLE fd = (*fop_fd)->filesystem_priv;
|
||||
|
||||
free(*fop_fd);
|
||||
*fop_fd = NULL;
|
||||
|
@ -92,7 +97,7 @@ _lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)
|
|||
LARGE_INTEGER l;
|
||||
|
||||
l.QuadPart = offset;
|
||||
if (!SetFilePointerEx((HANDLE)fop_fd->fd, l, NULL, FILE_CURRENT))
|
||||
if (!SetFilePointerEx((HANDLE)fop_fd->filesystem_priv, l, NULL, FILE_CURRENT))
|
||||
{
|
||||
lwsl_err("error seeking from cur %ld, offset %ld\n", (long)fop_fd->pos, (long)offset);
|
||||
return -1;
|
||||
|
@ -101,7 +106,7 @@ _lws_plat_file_seek_cur(lws_fop_fd_t fop_fd, lws_fileofs_t offset)
|
|||
LARGE_INTEGER zero;
|
||||
zero.QuadPart = 0;
|
||||
LARGE_INTEGER newPos;
|
||||
if (!SetFilePointerEx((HANDLE)fop_fd->fd, zero, &newPos, FILE_CURRENT))
|
||||
if (!SetFilePointerEx((HANDLE)fop_fd->filesystem_priv, zero, &newPos, FILE_CURRENT))
|
||||
{
|
||||
lwsl_err("error seeking from cur %ld, offset %ld\n", (long)fop_fd->pos, (long)offset);
|
||||
return -1;
|
||||
|
@ -117,7 +122,7 @@ _lws_plat_file_read(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
|
|||
{
|
||||
DWORD _amount;
|
||||
|
||||
if (!ReadFile((HANDLE)fop_fd->fd, buf, (DWORD)len, &_amount, NULL)) {
|
||||
if (!ReadFile((HANDLE)fop_fd->filesystem_priv, buf, (DWORD)len, &_amount, NULL)) {
|
||||
*amount = 0;
|
||||
|
||||
return 1;
|
||||
|
@ -135,7 +140,7 @@ _lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
|
|||
{
|
||||
DWORD _amount;
|
||||
|
||||
if (!WriteFile((HANDLE)fop_fd->fd, buf, (DWORD)len, &_amount, NULL)) {
|
||||
if (!WriteFile((HANDLE)fop_fd->filesystem_priv, buf, (DWORD)len, &_amount, NULL)) {
|
||||
*amount = 0;
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue