aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile/inc_chibiosfs.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-02-15 22:31:33 +1000
committerinmarket <andrewh@inmarket.com.au>2014-02-15 22:31:33 +1000
commitdcedf414136e55e6dacbe736babe748e1374e19e (patch)
treede3823534bfa37f9cc92c0dae3b474db8ece9088 /src/gfile/inc_chibiosfs.c
parent84fc1ac166fc2908b5840a78ceb515b4f14edd80 (diff)
parent5edf7c956e8a00a6a49e1f3c446c80cecf0e59ef (diff)
downloaduGFX-dcedf414136e55e6dacbe736babe748e1374e19e.tar.gz
uGFX-dcedf414136e55e6dacbe736babe748e1374e19e.tar.bz2
uGFX-dcedf414136e55e6dacbe736babe748e1374e19e.zip
Merge branch 'master' into gwin
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..87b8c110
--- /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, void *buf, int size);
+static int ChibiOSBFSWrite(GFILE *f, const void *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, void *buf, int size) {
+ return chSequentialStreamRead(((BaseFileStream *)f->fd), (uint8_t *)buf, size);
+}
+static int ChibiOSBFSWrite(GFILE *f, const void *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)); }