aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile/inc_chibiosfs.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-02-07 01:34:38 +1000
committerinmarket <andrewh@inmarket.com.au>2014-02-07 01:34:38 +1000
commite72e2705381558ff2347543ed21b853a1168858c (patch)
treef0e3026640e71e4a78b9d8f46bb9daea7cee8743 /src/gfile/inc_chibiosfs.c
parent9ef10b9ec669bd6af0747b083b1b61b4a041e206 (diff)
downloaduGFX-e72e2705381558ff2347543ed21b853a1168858c.tar.gz
uGFX-e72e2705381558ff2347543ed21b853a1168858c.tar.bz2
uGFX-e72e2705381558ff2347543ed21b853a1168858c.zip
Add support for GFILEs based on BaseFileStreams and Memory Pointers
Diffstat (limited to 'src/gfile/inc_chibiosfs.c')
-rw-r--r--src/gfile/inc_chibiosfs.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/gfile/inc_chibiosfs.c b/src/gfile/inc_chibiosfs.c
new file mode 100644
index 00000000..b30a675f
--- /dev/null
+++ b/src/gfile/inc_chibiosfs.c
@@ -0,0 +1,46 @@
+/*
+ * This file is subject to the terms of the GFX License. If a copy of
+ * the license was not distributed with this file, you can obtain one at:
+ *
+ * http://ugfx.org/license.html
+ */
+
+/**
+ * This file is included by src/gfile/gfile.c
+ */
+
+/********************************************************
+ * The ChibiOS BaseFileStream file-system VMT
+ ********************************************************/
+
+static void ChibiOSBFSClose(GFILE *f);
+static int ChibiOSBFSRead(GFILE *f, char *buf, int size);
+static int ChibiOSBFSWrite(GFILE *f, char *buf, int size);
+static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos);
+static long int ChibiOSBFSGetsize(GFILE *f);
+static bool_t ChibiOSBFSEof(GFILE *f);
+
+static const GFILEVMT FsCHIBIOSVMT = {
+ 0, // next
+ GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags
+ 0, // prefix
+ 0, 0, 0, 0,
+ 0, ChibiOSBFSClose, ChibiOSBFSRead, ChibiOSBFSWrite,
+ ChibiOSBFSSetpos, ChibiOSBFSGetsize, ChibiOSBFSEof,
+};
+
+static void ChibiOSBFSClose(GFILE *f) {
+ chFileStreamClose(((BaseFileStream *)f->fd));
+}
+static int ChibiOSBFSRead(GFILE *f, char *buf, int size) {
+ return chSequentialStreamRead(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
+}
+static int ChibiOSBFSWrite(GFILE *f, char *buf, int size) {
+ return chSequentialStreamWrite(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
+}
+static bool_t ChibiOSBFSSetpos(GFILE *f, long int pos) {
+ chFileStreamSeek(((BaseFileStream *)f->fd), pos);
+ return TRUE;
+}
+static long int ChibiOSBFSGetsize(GFILE *f) { return chFileStreamGetSize(((BaseFileStream *)f->fd)); }
+static bool_t ChibiOSBFSEof(GFILE *f) { return f->pos >= chFileStreamGetSize(((BaseFileStream *)f->fd)); }