3#include "osal/file/osal_file_types.h"
5#include "osal/file/osal_file_ops.h"
76 if (!s || !mem || !mem->
calloc || !mem->
free)
return NULL;
77 int len = MultiByteToWideChar(CP_UTF8, 0, s, -1, NULL, 0);
78 if (len <= 0)
return NULL;
80 wchar_t *w = (
wchar_t *)mem->
calloc((
size_t)len,
sizeof(*w));
83 int ok = MultiByteToWideChar(CP_UTF8, 0, s, -1, w, len);
92 const char *path_utf8,
98 if (!path_utf8 || !*path_utf8)
return NULL;
105 use_env = &default_env;
109 if (!mem || !mem->
calloc || !mem->
free)
return NULL;
112 if (!mode)
return NULL;
121 FILE *fp = _wfopen(wpath, mode);
146 if (!f || !f->
fp || (!buf && n))
return 0;
149 size_t got = fread(buf, 1, n, f->
fp);
166 if (!f || !f->
fp || (!buf && n))
return 0;
169 size_t put = fwrite(buf, 1, n, f->
fp);
static osal_file_status_t win_close(osal_file_t *f)
static const wchar_t * wmode_from_flags(uint32_t flags, osal_file_status_t *st)
static void set_status(osal_file_status_t *st, osal_file_status_t v)
const osal_file_ops_t * osal_file_win32_ops(void)
static size_t win_read(osal_file_t *f, void *buf, size_t n, osal_file_status_t *st)
static osal_file_t * win_open(const char *path_utf8, uint32_t flags, osal_file_status_t *st, const osal_file_env_t *env)
static size_t win_write(osal_file_t *f, const void *buf, size_t n, osal_file_status_t *st)
static osal_file_status_t win_flush(osal_file_t *f)
static osal_file_status_t map_errno(int e)
static wchar_t * utf8_to_wide(const char *s, const osal_mem_ops_t *mem)
void lexleo_panic(const char *msg) __attribute__((noreturn))
osal_file_env_t osal_file_default_env(const osal_mem_ops_t *mem_ops)
const osal_mem_ops_t * osal_mem_default_ops(void)
const osal_mem_ops_t * mem
osal_file_t *(* open)(const char *path_utf8, uint32_t flags, osal_file_status_t *status, const osal_file_env_t *env)
const osal_mem_ops_t * mem
void *(* calloc)(size_t nmemb, size_t size)