picox  0.1
xvfs.h
[詳解]
1 
14 /*
15  * License: MIT license
16  * Copyright (c) <2016> <MaskedW [maskedw00@gmail.com]>
17  *
18  * Permission is hereby granted, free of charge, to any person
19  * obtaining a copy of this software and associated documentation
20  * files (the "Software"), to deal in the Software without
21  * restriction, including without limitation the rights to use, copy,
22  * modify, merge, publish, distribute, sublicense, and/or sell copies
23  * of the Software, and to permit persons to whom the Software is
24  * furnished to do so, subject to the following conditions:
25  *
26  * The above copyright notice and this permission notice shall be
27  * included in all copies or substantial portions of the Software.
28  *
29  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
33  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
34  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36  * SOFTWARE.
37  */
38 
39 #ifndef picox_filesystem_xvfs_h_
40 #define picox_filesystem_xvfs_h_
41 
42 
44 
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif /* __cplusplus */
49 
50 
71 #define X_VFS_TAG (X_MAKE_TAG('X', 'V', 'I', 'F'))
72 
73 
76 XStream* xvfs_init_stream(XStream* stream, XFile* fp);
77 
78 
89 XError xvfs_open(XVirtualFs* vfs, const char* path, XOpenMode mode, XFile** o_fp);
90 
91 
100 XError xvfs_close(XFile* fp);
101 
102 
116 XError xvfs_read(XFile* fp, void* dst, size_t size, size_t* nread);
117 
118 
129 XError xvfs_write(XFile* fp, const void* src, size_t size, size_t* nwritten);
130 
131 
146 XError xvfs_seek(XFile* fp, XOffset pos, XSeekMode whence);
147 
148 
157 XError xvfs_tell(XFile* fp, XSize* pos);
158 
159 
173 XError xvfs_flush(XFile* fp);
174 
175 
183 XError xvfs_mkdir(XVirtualFs* vfs, const char* path);
184 
185 
195 XError xvfs_opendir(XVirtualFs* vfs, const char* path, XDir** o_dir);
196 
197 
208 XError xvfs_readdir(XDir* dir, XDirEnt* dirent, XDirEnt** result);
209 
210 
218 
219 
225 XError xvfs_chdir(XVirtualFs* vfs, const char* path);
226 
227 
235 XError xvfs_getcwd(XVirtualFs* vfs, char* buf, size_t size);
236 
237 
245 XError xvfs_remove(XVirtualFs* vfs, const char* path);
246 
247 
262 XError xvfs_rename(XVirtualFs* vfs, const char* oldpath, const char* newpath);
263 
264 
273 XError xvfs_stat(XVirtualFs* vfs, const char* path, XStat* statbuf);
274 
275 
283 XError xvfs_utime(XVirtualFs* vfs, const char* path, XTime time);
284 
285 
288 int xvfs_putc(XFile* fp, int c);
289 
290 
293 int xvfs_puts(XFile* fp, const char* str);
294 
295 
298 int xvfs_printf(XFile* fp, const char* fmt, ...);
299 
300 
303 int xvfs_vprintf(XFile* fp, const char* fmt, va_list args);
304 
305 
308 int xvfs_getc(XFile* fp);
309 
310 
315 XError xvfs_gets(XFile* fp, char* dst, size_t size, char** result, bool* overflow);
316 
317 
323 XError xvfs_exists(XVirtualFs* vfs, const char* path, bool* exists);
324 
325 
331 XError xvfs_is_directory(XVirtualFs* vfs, const char* path, bool* isdir);
332 
333 
339 XError xvfs_is_regular(XVirtualFs* vfs, const char* path, bool* isreg);
340 
341 
350 XError xvfs_copyfile(XVirtualFs* vfs, const char* src, const char* dst);
351 
352 
361 XError xvfs_copyfile2(XFile* src, XFile* dst);
362 
363 
374 XError xvfs_copytree(XVirtualFs* vfs, const char* src, const char* dst);
375 
376 
384 XError xvfs_rmtree(XVirtualFs* vfs, const char* path);
385 
386 
398 XError xvfs_makedirs(XVirtualFs* vfs, const char* path, bool exist_ok);
399 
400 
410 XError xvfs_walktree(XVirtualFs* vfs, const char* path, XFsTreeWalker walker, void* userptr);
411 
412 
418 #ifdef __cplusplus
419 }
420 #endif /* __cplusplus */
421 
422 
423 #endif /* picox_filesystem_xvfs_h_ */
XError xvfs_stat(XVirtualFs *vfs, const char *path, XStat *statbuf)
エントリの状態を取得します
Definition: xvfs.c:284
int xvfs_puts(XFile *fp, const char *str)
ファイルに文字列を書き込みます
Definition: xvfs.c:338
Definition: xfscore.h:182
uint32_t XTime
time_tの代替をするシステム時刻を格納するための型です
Definition: xtime.h:80
XError xvfs_read(XFile *fp, void *dst, size_t size, size_t *nread)
ファイルからデータを読み込みます
Definition: xvfs.c:151
XOpenMode
ファイルオープン等のモードです
Definition: xstddef.h:435
XError xvfs_rmtree(XVirtualFs *vfs, const char *path)
ディレクトリツリーを削除します
Definition: xvfs.c:496
XError
errnoの代替として使用する共通のエラーコードを表す列挙型です
Definition: xstddef.h:367
ディレクトリエントリ情報を格納する構造体です
Definition: xfscore.h:109
XError xvfs_opendir(XVirtualFs *vfs, const char *path, XDir **o_dir)
ディレクトリをオープンします
Definition: xvfs.c:215
bool(* XFsTreeWalker)(void *userptr, const char *path, const XStat *statbuf, const XDirEnt *dirent)
ディレクトリ探索関数が呼び出すコールバック関数型です
Definition: xfscore.h:124
XError xvfs_copyfile2(XFile *src, XFile *dst)
ファイルをコピーします
Definition: xvfs.c:404
XError xvfs_is_regular(XVirtualFs *vfs, const char *path, bool *isreg)
パスが通常ファイルかどうかを判定します
Definition: xvfs.c:320
XError xvfs_open(XVirtualFs *vfs, const char *path, XOpenMode mode, XFile **o_fp)
ファイルをオープンします
Definition: xvfs.c:129
XError xvfs_mkdir(XVirtualFs *vfs, const char *path)
ディレクトリを作成します
Definition: xvfs.c:206
uint32_t XSize
何らかの大きさを表すのに十分なサイズを備えた符号なし整数型です
Definition: xstddef.h:251
XError xvfs_copytree(XVirtualFs *vfs, const char *src, const char *dst)
ディレクトリツリーをコピーします
Definition: xvfs.c:451
ファイル操作のハンドル構造体です
Definition: xfscore.h:70
XError xvfs_makedirs(XVirtualFs *vfs, const char *path, bool exist_ok)
ディレクトリを作成します
Definition: xvfs.c:520
XError xvfs_copyfile(XVirtualFs *vfs, const char *src, const char *dst)
ファイルをコピーします
Definition: xvfs.c:380
int xvfs_getc(XFile *fp)
ファイルから1文字を読み込みます
Definition: xvfs.c:363
XError xvfs_is_directory(XVirtualFs *vfs, const char *path, bool *isdir)
パスがディレクトリかどうかを判定します
Definition: xvfs.c:310
XError xvfs_close(XFile *fp)
ファイルをクローズします
Definition: xvfs.c:139
XError xvfs_closedir(XDir *dir)
ディレクトリをクローズします
Definition: xvfs.c:238
XError xvfs_gets(XFile *fp, char *dst, size_t size, char **result, bool *overflow)
ファイルから1行を読み込みます
Definition: xvfs.c:372
XError xvfs_remove(XVirtualFs *vfs, const char *path)
エントリを削除します
Definition: xvfs.c:268
XError xvfs_tell(XFile *fp, XSize *pos)
ファイル位置を取得します
Definition: xvfs.c:184
XError xvfs_exists(XVirtualFs *vfs, const char *path, bool *exists)
パスが存在するかどうかを判定します
Definition: xvfs.c:300
int xvfs_printf(XFile *fp, const char *fmt,...)
ファイルにprintf形式で文字列を書き込みます
Definition: xvfs.c:345
XError xvfs_readdir(XDir *dir, XDirEnt *dirent, XDirEnt **result)
ディレクトリから要素を読み込みます
Definition: xvfs.c:227
XError xvfs_chdir(XVirtualFs *vfs, const char *path)
カレントディレクトリを変更します
Definition: xvfs.c:252
XError xvfs_write(XFile *fp, const void *src, size_t size, size_t *nwritten)
ファイルにデータを書き込みます
Definition: xvfs.c:162
XError xvfs_getcwd(XVirtualFs *vfs, char *buf, size_t size)
カレントディレクトリを取得します
Definition: xvfs.c:260
XError xvfs_seek(XFile *fp, XOffset pos, XSeekMode whence)
ファイル位置を変更します
Definition: xvfs.c:173
int xvfs_vprintf(XFile *fp, const char *fmt, va_list args)
ファイルにvprintf形式で文字列を書き込みます
Definition: xvfs.c:355
int32_t XOffset
何らかのオフセットを表すのに十分な大きさをもった符号あり整数型です
Definition: xstddef.h:261
ストリームを表す抽象型です
Definition: xstream.h:152
XSeekMode
シークの起点を指定する列挙型です
Definition: xstddef.h:340
int xvfs_putc(XFile *fp, int c)
ファイルに1文字を書き込みます
Definition: xvfs.c:330
XStream * xvfs_init_stream(XStream *stream, XFile *fp)
Definition: xvfs.c:112
XError xvfs_walktree(XVirtualFs *vfs, const char *path, XFsTreeWalker walker, void *userptr)
ディレクトリツリーを走査します
Definition: xvfs.c:548
ディレクトリ操作のハンドル構造体です
Definition: xfscore.h:82
XError xvfs_flush(XFile *fp)
バッファされたデータを出力します
Definition: xvfs.c:195
ファイル情報を格納する構造体です
Definition: xfscore.h:92
XError xvfs_rename(XVirtualFs *vfs, const char *oldpath, const char *newpath)
エントリの名前や位置を変更します
Definition: xvfs.c:276
XError xvfs_utime(XVirtualFs *vfs, const char *path, XTime time)
エントリのタイムスタンプを変更します
Definition: xvfs.c:292