LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
osal_file.c
Go to the documentation of this file.
1// src/foundation/osal/src/common/osal_file.c
2
3#include "internal/osal_file_internal.h"
4
7#include "osal/file/osal_file_ops.h"
8
10
12
14#if defined(_WIN32) || defined(_WIN64)
15 return osal_file_win32_ops();
16#else
17 return osal_file_posix_ops();
18#endif
19}
20
22 if (st) *st = v;
23}
24
26 const char *path_utf8,
27 uint32_t flags,
28 osal_file_status_t *status,
29 const osal_file_env_t *env )
30{
32 if (!ops || !ops->open) {
34 return NULL;
35 }
36 return ops->open(path_utf8, flags, status, env);
37}
38
40 osal_file_t *f,
41 void *buf,
42 size_t n,
43 osal_file_status_t *status)
44{
46 if (!ops || !ops->read) {
48 return 0;
49 }
50 return ops->read(f, buf, n, status);
51}
52
54 osal_file_t *f,
55 const void *buf,
56 size_t n,
57 osal_file_status_t *status)
58{
60 if (!ops || !ops->write) {
62 return 0;
63 }
64 return ops->write(f, buf, n, status);
65}
66
68{
70 if (!ops || !ops->flush) return OSAL_FILE_NOSYS;
71 return ops->flush(f);
72}
73
75{
77 if (!ops || !ops->close) return OSAL_FILE_NOSYS;
78 return ops->close(f);
79}
80
83 env.mem = mem ? mem : osal_mem_default_ops();
84 return env;
85}
osal_file_status_t
@ OSAL_FILE_NOSYS
const osal_file_ops_t * osal_file_posix_ops(void)
const osal_file_ops_t * osal_file_win32_ops(void)
size_t osal_file_read(osal_file_t *f, void *buf, size_t n, osal_file_status_t *status)
Definition osal_file.c:39
osal_file_status_t osal_file_flush(osal_file_t *f)
Definition osal_file.c:67
osal_file_status_t osal_file_close(osal_file_t *f)
Definition osal_file.c:74
osal_file_env_t osal_file_default_env(const osal_mem_ops_t *mem)
Definition osal_file.c:81
static void set_status(osal_file_status_t *st, osal_file_status_t v)
Definition osal_file.c:21
size_t osal_file_write(osal_file_t *f, const void *buf, size_t n, osal_file_status_t *status)
Definition osal_file.c:53
osal_file_t * osal_file_open(const char *path_utf8, uint32_t flags, osal_file_status_t *status, const osal_file_env_t *env)
Definition osal_file.c:25
const osal_file_ops_t * osal_file_default_ops(void)
Return the default OSAL file operations for the active platform.
Definition osal_file.c:13
const osal_mem_ops_t * osal_mem_default_ops(void)
const osal_mem_ops_t * mem
size_t(* write)(osal_file_t *f, const void *buf, size_t n, osal_file_status_t *status)
osal_file_status_t(* close)(osal_file_t *f)
osal_file_status_t(* flush)(osal_file_t *f)
size_t(* read)(osal_file_t *f, void *buf, size_t n, osal_file_status_t *status)
osal_file_t *(* open)(const char *path_utf8, uint32_t flags, osal_file_status_t *status, const osal_file_env_t *env)