Subject: windows: fops write support

This commit is contained in:
Joel Winarske 2017-04-19 14:55:21 -07:00 committed by Andy Green
parent aeb3397c8f
commit 991f6ec644
2 changed files with 17 additions and 9 deletions

View file

@ -84,6 +84,9 @@ struct sockaddr_in;
#define LWS_INVALID_FILE INVALID_HANDLE_VALUE
#define LWS_O_RDONLY _O_RDONLY
#define LWS_O_WRONLY _O_WRONLY
#define LWS_O_CREAT _O_CREAT
#define LWS_O_TRUNC _O_TRUNC
#if !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER < 1900) /* Visual Studio 2015 already defines this in <stdio.h> */
#define lws_snprintf _snprintf
@ -106,6 +109,9 @@ struct sockaddr_in;
#define LWS_INLINE inline
#define LWS_O_RDONLY O_RDONLY
#define LWS_O_WRONLY O_WRONLY
#define LWS_O_CREAT O_CREAT
#define LWS_O_TRUNC O_TRUNC
#if !defined(LWS_WITH_ESP8266) && !defined(OPTEE_TA) && !defined(LWS_WITH_ESP32)
#include <poll.h>

View file

@ -538,8 +538,8 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename,
ret = CreateFileW(buf, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
} else {
lwsl_err("%s: open for write not implemented\n", __func__);
goto bail;
ret = CreateFileW(buf, GENERIC_WRITE, 0, NULL,
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (ret == LWS_INVALID_FILE)
@ -603,16 +603,18 @@ LWS_VISIBLE int
_lws_plat_file_write(lws_fop_fd_t fop_fd, lws_filepos_t *amount,
uint8_t* buf, lws_filepos_t len)
{
(void)fop_fd;
(void)amount;
(void)buf;
(void)len;
DWORD _amount;
fop_fd->pos += len;
if (!WriteFile((HANDLE)fop_fd->fd, buf, (DWORD)len, &_amount, NULL)) {
*amount = 0;
lwsl_err("%s: not implemented yet on this platform\n", __func__);
return 1;
}
return -1;
fop_fd->pos += _amount;
*amount = (unsigned long)_amount;
return 0;
}
LWS_VISIBLE int