version 2.8
gfile_fs.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 /**
9  * @file src/gfile/gfile_fs.h
10  * @brief GFILE file system header.
11  *
12  */
13 
14 #ifndef _GFILE_FS_H
15 #define _GFILE_FS_H
16 
17 struct GFILE {
18  const struct GFILEVMT * vmt;
19  uint16_t flags;
20  #define GFILEFLG_OPEN 0x0001 // File is open
21  #define GFILEFLG_READ 0x0002 // Read the file
22  #define GFILEFLG_WRITE 0x0004 // Write the file
23  #define GFILEFLG_APPEND 0x0008 // Append on each write
24  #define GFILEFLG_BINARY 0x0010 // Treat as a binary file
25  #define GFILEFLG_DELONCLOSE 0x0020 // Delete on close
26  #define GFILEFLG_CANSEEK 0x0040 // Seek operations are valid
27  #define GFILEFLG_FAILONBLOCK 0x0080 // Fail on a blocking call
28  #define GFILEFLG_MUSTEXIST 0x0100 // On open file must exist
29  #define GFILEFLG_MUSTNOTEXIST 0x0200 // On open file must not exist
30  #define GFILEFLG_TRUNC 0x0400 // On open truncate the file
31  void * obj;
32  long int pos;
33 };
34 
35 struct gfileList {
36  const struct GFILEVMT * vmt;
37  bool_t dirs;
38 };
39 
40 typedef struct GFILEVMT {
41  uint8_t flags;
42  #define GFSFLG_WRITEABLE 0x0001
43  #define GFSFLG_CASESENSITIVE 0x0002
44  #define GFSFLG_SEEKABLE 0x0004
45  #define GFSFLG_FAST 0x0010
46  #define GFSFLG_SMALL 0x0020
47  #define GFSFLG_TEXTMODES 0x0040
48  char prefix;
49  bool_t (*del) (const char *fname);
50  bool_t (*exists) (const char *fname);
51  long int (*filesize) (const char *fname);
52  bool_t (*ren) (const char *oldname, const char *newname);
53  bool_t (*open) (GFILE *f, const char *fname);
54  void (*close) (GFILE *f);
55  int (*read) (GFILE *f, void *buf, int size);
56  int (*write) (GFILE *f, const void *buf, int size);
57  bool_t (*setpos) (GFILE *f, long int pos);
58  long int (*getsize) (GFILE *f);
59  bool_t (*eof) (GFILE *f);
60  bool_t (*mount) (const char *drive);
61  bool_t (*unmount) (const char *drive);
62  bool_t (*sync) (GFILE *f);
63  #if GFILE_NEED_FILELISTS
64  gfileList * (*flopen) (const char *path, bool_t dirs);
65  const char *(*flread) (gfileList *pfl);
66  void (*flclose) (gfileList *pfl);
67  #endif
68 } GFILEVMT;
69 
70 GFILE *_gfileFindSlot(const char *mode);
71 
72 #endif //_GFILE_FS_H
struct GFILE GFILE
A file pointer.
Definition: gfile.h:34