4#include "osal/file/osal_file_ops.h"
5#include "osal/file/osal_file_types.h"
84 const char *path_utf8,
90 if (!path_utf8 || !*path_utf8)
return NULL;
97 use_env = &default_env;
101 if (!mem || !mem->
calloc || !mem->
free)
return NULL;
104 if (!mode)
return NULL;
107 FILE *fp = fopen(path_utf8, mode);
134 if (!f || !f->
fp || (!buf && n))
return 0;
139 size_t got = fread(buf, 1, n, f->
fp);
164 if (!f || !f->
fp || (!buf && n))
return 0;
169 size_t put = fwrite(buf, 1, n, f->
fp);
192 if (fflush(f->
fp) != 0) {
216 if (fclose(f->
fp) != 0) {
static size_t posix_write(osal_file_t *f, const void *buf, size_t n, osal_file_status_t *st)
static size_t posix_read(osal_file_t *f, void *buf, size_t n, osal_file_status_t *st)
const osal_file_ops_t * osal_file_posix_ops(void)
static void set_status(osal_file_status_t *st, osal_file_status_t v)
static osal_file_t * posix_open(const char *path_utf8, uint32_t flags, osal_file_status_t *st, const osal_file_env_t *env)
static osal_file_status_t posix_close(osal_file_t *f)
static osal_file_status_t map_errno(int e)
static const char * mode_from_flags(uint32_t flags, osal_file_status_t *st)
static osal_file_status_t posix_flush(osal_file_t *f)
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)