GadgetSeed  0.9.6
fs.h
[詳解]
1 /** @file
2  @brief ファイルシステムAPI
3 
4  @date 2018.09.09
5  @author Takashi SHUDO
6 */
7 
8 #ifndef FS_H
9 #define FS_H
10 
11 #include "str.h"
12 #include "datetime.h"
13 #include "device.h"
14 
15 #define FSNAME_VFAT "vfat"
16 #define FSNAME_PIPE "pipe"
17 
18 #ifdef GSC_COMP_ENABLE_FATFS
19 #include "ff.h"
20 #if FF_USE_LFN
21 #define MAX_FNAME_LEN FF_MAX_LFN
22 #else
23 #define MAX_FNAME_LEN 12
24 #endif
25 #else
26 #define MAX_FNAME_LEN 63
27 #endif
28 
29 #if 1
30 typedef unsigned long long t_size;
31 typedef long long t_ssize;
32 #else
33 typedef unsigned int t_size;
34 typedef int t_ssize;
35 #endif
36 
37 typedef struct {
38  t_size fsize;
39  t_time fdatetime;
40  unsigned int fattrib;
41  uchar fname[MAX_FNAME_LEN + 1];
42 } FS_FILEINFO; ///< ファイル情報
43 
44 typedef struct {
45  struct st_filesystem *fs;
46  union {
47 #ifdef GSC_COMP_ENABLE_FATFS
48  DIR dir;
49 #endif
50 #ifdef GSC_COMP_ENABLE_PIPEFS
51  int finfo_cnt;
52 #endif
53  } dir;
54 } FS_DIR; ///< ディレクトリ情報
55 
56 struct st_filesystem {
57  char *name;
58  int (* mount)(int drvno, struct st_device *dev);
59  int (* unmount)(int drvno, struct st_device *dev);
60 
61  void * (* open)(const uchar *path, int flags);
62  t_ssize (* read)(void *fd, void *buf, t_size count);
63  t_ssize (* write)(void *fd, const void *buf, t_size count);
64  t_ssize (* seek)(void *fd, t_ssize offset, int whence);
65  t_size (* tell)(void *fd);
66  int (* close)(void *fd);
67  FS_DIR * (* opendir)(const uchar *name);
68  int (* readdir)(FS_DIR *dir, FS_FILEINFO *finfo);
69  int (* closedir)(FS_DIR *dir);
70  int (* stat)(const uchar *path, FS_FILEINFO *finfo);
71  int (* getfree)(const uchar *path, unsigned long *sect, void **fso);
72  int (* sync)(void *fd);
73  int (* unlink)(const uchar *path);
74  int (* mkdir)(const uchar *path);
75  int (* chmod)(const uchar *path, unsigned char flag);
76  int (* rename)(const uchar *oldpath, const uchar *newpath);
77  int (* mkfs)(const uchar *path, unsigned char part, unsigned short alloc);
78 }; ///< ファイルシステム構造体
79 
80 extern struct st_filesystem * search_filesystem(const char *name);
81 
82 #endif // FS_H
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
Definition: str.h:13
ファイルシステム構造体
Definition: fs.h:56
Definition: fs.h:44
文字列処理
日付時刻
Definition: fs.h:37
デバイスドライバAPI
デバイスドライバ構造体
Definition: device.h:25
char name[MAX_DEVNAMELRN]
デバイス名文字列
Definition: device.h:26