23#include "internal/osal_file_internal.h"
25#include "osal/file/osal_file_ops.h"
192 const char *pathname,
199 || pathname[0] ==
'\0'
221 FILE *fp = fopen(pathname, mode);
278 size_t ret = fread(ptr, size, nmemb, stream->
fp);
280 if (ret < nmemb && ferror(stream->
fp)) {
331 size_t ret = fwrite(ptr, size, nmemb, stream->
fp);
333 if (ret < nmemb && ferror(stream->
fp)) {
355 if (!stream || !stream->
fp) {
359 if (fflush(stream->
fp) != 0) {
381 if (!stream || !stream->
fp) {
385 if (fclose(stream->
fp) != 0) {
@ OSAL_FILE_STATUS_EXISTS
@ OSAL_FILE_STATUS_NAMETOOLONG
@ OSAL_FILE_STATUS_INVALID
@ OSAL_FILE_STATUS_NOTDIR
#define LEXLEO_ASSERT(expr)
int osal_strcmp(const char *s1, const char *s2)
static size_t osal_file_read(void *ptr, size_t size, size_t nmemb, OSAL_FILE *stream, osal_file_status_t *st)
Read elements from an open OSAL_FILE.
static size_t osal_file_write(const void *ptr, size_t size, size_t nmemb, OSAL_FILE *stream, osal_file_status_t *st)
Write elements to an open OSAL_FILE.
static osal_file_status_t osal_file_map_errno(int errnum)
Map a platform errno value to an osal_file_status_t.
static osal_file_status_t osal_file_close(OSAL_FILE *stream)
Close an open OSAL_FILE and release its associated wrapper.
const osal_file_ops_t * osal_file_default_ops(void)
Return the default POSIX / C stdio OSAL file operations table.
static osal_file_status_t osal_file_open(OSAL_FILE **out, const char *pathname, const char *mode, const osal_mem_ops_t *mem_ops)
Open a file resource through the POSIX / C stdio backend.
static osal_file_status_t osal_file_flush(OSAL_FILE *stream)
Flush buffered output associated with an open OSAL_FILE.
Private representation of an acquired OSAL file handle.
FILE * fp
Underlying C standard I/O file handle.
const osal_mem_ops_t * mem_ops
Memory operations table used to release this wrapper.
Operations table for the low-level OSAL file abstraction.
osal_file_status_t(* open)(OSAL_FILE **out, const char *pathname, const char *mode, const osal_mem_ops_t *mem_ops)
Open a file resource.
void *(* malloc)(size_t size)