VSF Documented
vsf_memfs.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_MEMFS_H__
19#define __VSF_MEMFS_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "../../vsf_fs_cfg.h"
24
25#if VSF_USE_FS == ENABLED && VSF_FS_USE_MEMFS == ENABLED
26
27#if defined(__VSF_MEMFS_CLASS_IMPLEMENT)
28# undef __VSF_MEMFS_CLASS_IMPLEMENT
29# define __VSF_CLASS_IMPLEMENT__
30#endif
31
32#include "utilities/ooc_class.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38/*============================ MACROS ========================================*/
39/*============================ MACROFIED FUNCTIONS ===========================*/
40/*============================ TYPES =========================================*/
41
42__vsf_component_peda_ifs(vk_memfs_callback_read,
46 uint32_t rsize;
47)
48__vsf_component_peda_ifs(vk_memfs_callback_write,
53)
54
56 public_member(
57 implement(vk_file_t)
58
59 union {
60 struct {
62 } f;
63 struct {
64 vk_memfs_file_t *child;
65 uint16_t child_num;
66 uint16_t child_size;
67 } d;
68 };
69 struct {
70 void (*fn_read)(uintptr_t target, vsf_evt_t evt);
71 void (*fn_write)(uintptr_t target, vsf_evt_t evt);
72 } callback;
73 )
74};
75
76typedef struct vk_memfs_info_t {
79
80/*============================ GLOBAL VARIABLES ==============================*/
81
82extern const vk_fs_op_t vk_memfs_op;
83
84/*============================ PROTOTYPES ====================================*/
85
86extern void vk_memfs_init(vk_memfs_info_t *memfs);
87extern vk_memfs_file_t * vk_memfs_open(vk_memfs_file_t *dir, const char *path);
92
93#ifdef __cplusplus
94}
95#endif
96
97#endif // VSF_USE_FS && VSF_FS_USE_MEMFS
98#endif // __VSF_MEMFS_H__
Definition vsf_fs.h:114
Definition vsf_fs.h:92
Definition vsf_memfs.h:55
#define vsf_class(__name)
Definition ooc_class.h:48
uint32_t uintptr_t
Definition stdint.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
int int_fast32_t
Definition stdint.h:26
unsigned long long uint64_t
Definition stdint.h:11
unsigned long long uint_fast64_t
Definition stdint.h:29
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_memfs.h:76
vk_memfs_file_t root
Definition vsf_memfs.h:77
#define __vsf_component_peda_ifs(__peda_name,...)
Definition vsf_component_cfg.h:62
int16_t vsf_evt_t
Definition vsf_eda.h:654
void vk_memfs_init(vk_memfs_info_t *memfs)
Definition vsf_memfs.c:249
int_fast32_t vk_memfs_write(vk_memfs_file_t *file, uint8_t *buff, uint_fast32_t size)
Definition vsf_memfs.c:314
uint_fast64_t vk_memfs_setpos(vk_memfs_file_t *file, uint_fast64_t offset)
Definition vsf_memfs.c:295
uint_fast64_t vk_memfs_tell(vk_memfs_file_t *file)
Definition vsf_memfs.c:290
uint32_t wsize
Definition vsf_memfs.h:52
vk_memfs_file_t * vk_memfs_open(vk_memfs_file_t *dir, const char *path)
Definition vsf_memfs.c:255
uint64_t offset
Definition vsf_memfs.h:49
const vk_fs_op_t vk_memfs_op
uint8_t * buff
Definition vsf_memfs.h:51
uint32_t size
Definition vsf_memfs.h:50
int_fast32_t vk_memfs_read(vk_memfs_file_t *file, uint8_t *buff, uint_fast32_t size)
Definition vsf_memfs.c:302