Mercurial > molko
comparison src/libmlk-core/core/vfs.h @ 332:8eee6f92e9ce
core: implement vfs and vfs-directory
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 13 Oct 2021 15:03:18 +0200 |
parents | |
children | 979960e65f76 |
comparison
equal
deleted
inserted
replaced
331:5c3f2aa95343 | 332:8eee6f92e9ce |
---|---|
1 /* | |
2 * vfs.h -- virtual file system abstraction | |
3 * | |
4 * Copyright (c) 2020-2021 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #ifndef MLK_CORE_VFS_H | |
20 #define MLK_CORE_VFS_H | |
21 | |
22 #include "core.h" | |
23 | |
24 struct vfs_file; | |
25 | |
26 struct vfs { | |
27 void *data; | |
28 int (*open)(struct vfs *, struct vfs_file *, const char *, const char *); | |
29 void (*finish)(struct vfs *); | |
30 }; | |
31 | |
32 struct vfs_file { | |
33 void *data; | |
34 size_t (*read)(struct vfs_file *, void *, size_t); | |
35 size_t (*write)(struct vfs_file *, const void *, size_t); | |
36 int (*flush)(struct vfs_file *); | |
37 void (*finish)(struct vfs_file *); | |
38 }; | |
39 | |
40 CORE_BEGIN_DECLS | |
41 | |
42 /* vfs */ | |
43 | |
44 int | |
45 vfs_open(struct vfs *, struct vfs_file *, const char *, const char *); | |
46 | |
47 void | |
48 vfs_finish(struct vfs *); | |
49 | |
50 /* vfs_file */ | |
51 | |
52 size_t | |
53 vfs_file_read(struct vfs_file *, void *, size_t); | |
54 | |
55 size_t | |
56 vfs_file_write(struct vfs_file *, void *, size_t); | |
57 | |
58 int | |
59 vfs_file_flush(struct vfs_file *); | |
60 | |
61 void | |
62 vfs_file_finish(struct vfs_file *); | |
63 | |
64 CORE_END_DECLS | |
65 | |
66 #endif /* MLK_CORE_VFS_H */ |