From fa8167b94d13e94a6cb953e7f549a89f155f77c6 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 21 Jan 2015 17:26:24 +1000 Subject: Big file rename to reduce problems with brain-dead IDE's that don't handle project file hierarchies well. Naming is more consistent with the new scheme. May affect some third party drivers (header file renames). --- src/gfile/gfile.c | 401 ++++++++++++++++++++++++++ src/gfile/gfile.h | 470 +++++++++++++++++++++++++++++++ src/gfile/gfile.mk | 18 ++ src/gfile/gfile_fatfs_diskio_chibios.c | 6 - src/gfile/gfile_fatfs_wrapper.c | 6 - src/gfile/gfile_gfile.c | 407 -------------------------- src/gfile/gfile_options.h | 207 ++++++++++++++ src/gfile/gfile_petitfs_diskio_chibios.c | 6 - src/gfile/gfile_petitfs_wrapper.c | 6 - src/gfile/gfile_rules.h | 26 ++ src/gfile/sys_defs.h | 470 ------------------------------- src/gfile/sys_make.mk | 18 -- src/gfile/sys_options.h | 207 -------------- src/gfile/sys_rules.h | 26 -- 14 files changed, 1122 insertions(+), 1152 deletions(-) create mode 100644 src/gfile/gfile.c create mode 100644 src/gfile/gfile.h create mode 100644 src/gfile/gfile.mk delete mode 100644 src/gfile/gfile_gfile.c create mode 100644 src/gfile/gfile_options.h create mode 100644 src/gfile/gfile_rules.h delete mode 100644 src/gfile/sys_defs.h delete mode 100644 src/gfile/sys_make.mk delete mode 100644 src/gfile/sys_options.h delete mode 100644 src/gfile/sys_rules.h (limited to 'src/gfile') diff --git a/src/gfile/gfile.c b/src/gfile/gfile.c new file mode 100644 index 00000000..4c22e6cc --- /dev/null +++ b/src/gfile/gfile.c @@ -0,0 +1,401 @@ +/* + * 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 + */ + +#include "gfx.h" + +#if GFX_USE_GFILE + +#include "gfile_fs.h" + +/** + * Define the VMT's for the file-systems we want to search for files. + * Virtual file-systems that have special open() calls do not need to + * be in this list. + */ +#if GFILE_NEED_ROMFS + extern const GFILEVMT FsROMVMT; +#endif +#if GFILE_NEED_NATIVEFS + extern const GFILEVMT FsNativeVMT; +#endif +#if GFILE_NEED_FATFS + extern const GFILEVMT FsFatFSVMT; +#endif +#if GFILE_NEED_RAMFS + extern const GFILEVMT FsRAMVMT; +#endif + + +/** + * The order of the file-systems below determines the order + * that they are searched to find a file. + */ +static const GFILEVMT const * FsArray[] = { + #if GFILE_NEED_ROMFS + &FsROMVMT, + #endif + #if GFILE_NEED_NATIVEFS + &FsNativeVMT, + #endif + #if GFILE_NEED_FATFS + &FsFatFSVMT, + #endif + #if GFILE_NEED_RAMFS + &FsRAMVMT, + #endif +}; + +/* + * The table of GFILE's + */ +static GFILE gfileArr[GFILE_MAX_GFILES]; +GFILE *gfileStdIn; +GFILE *gfileStdOut; +GFILE *gfileStdErr; + +/** + * The init routine + */ +void _gfileInit(void) { + #if GFILE_NEED_NATIVEFS + extern void _gfileNativeAssignStdio(void); + _gfileNativeAssignStdio(); + #endif +} + +void _gfileDeinit(void) +{ + /* ToDo */ +} + +/** + * Internal routine to find an empty GFILE slot and interpret flags. + */ +GFILE *_gfileFindSlot(const char *mode) { + GFILE * f; + + // First find an available GFILE slot. + for (f = gfileArr; f < &gfileArr[GFILE_MAX_GFILES]; f++) { + if (!(f->flags & GFILEFLG_OPEN)) { + // Get the flags + switch(mode[0]) { + case 'r': + f->flags = GFILEFLG_READ|GFILEFLG_MUSTEXIST; + while (*++mode) { + switch(mode[0]) { + case '+': f->flags |= GFILEFLG_WRITE; break; + case 'b': f->flags |= GFILEFLG_BINARY; break; + } + } + break; + case 'w': + f->flags = GFILEFLG_WRITE|GFILEFLG_TRUNC; + while (*++mode) { + switch(mode[0]) { + case '+': f->flags |= GFILEFLG_READ; break; + case 'b': f->flags |= GFILEFLG_BINARY; break; + case 'x': f->flags |= GFILEFLG_MUSTNOTEXIST; break; + } + } + break; + case 'a': + f->flags = GFILEFLG_WRITE|GFILEFLG_APPEND; + while (*++mode) { + switch(mode[0]) { + case '+': f->flags |= GFILEFLG_READ; break; + case 'b': f->flags |= GFILEFLG_BINARY; break; + case 'x': f->flags |= GFILEFLG_MUSTNOTEXIST; break; + } + } + break; + default: + return 0; + } + return f; + } + } + return 0; +} + +/******************************************************** + * IO routines + ********************************************************/ + +bool_t gfileExists(const char *fname) { + const GFILEVMT * const *p; + + #if GFILE_ALLOW_DEVICESPECIFIC + if (fname[0] && fname[1] == '|') { + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fname[0]) + return p[0]->exists && p[0]->exists(fname+2); + } + return FALSE; + } + #endif + + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->exists && p[0]->exists(fname)) + return TRUE; + } + return FALSE; +} + +bool_t gfileDelete(const char *fname) { + const GFILEVMT **p; + + #if GFILE_ALLOW_DEVICESPECIFIC + if (fname[0] && fname[1] == '|') { + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fname[0]) + return p[0]->del && p[0]->del(fname+2); + } + return FALSE; + } + #endif + + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->del && p[0]->del(fname)) + return TRUE; + } + return FALSE; +} + +long int gfileGetFilesize(const char *fname) { + const GFILEVMT * const *p; + long int res; + + #if GFILE_ALLOW_DEVICESPECIFIC + if (fname[0] && fname[1] == '|') { + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fname[0]) + return p[0]->filesize ? p[0]->filesize(fname+2) : -1; + } + return -1; + } + #endif + + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->filesize && (res = p[0]->filesize(fname)) != -1) + return res; + } + return -1; +} + +bool_t gfileRename(const char *oldname, const char *newname) { + const GFILEVMT * const *p; + + #if GFILE_ALLOW_DEVICESPECIFIC + if ((oldname[0] && oldname[1] == '|') || (newname[0] && newname[1] == '|')) { + char ch; + + if (oldname[0] && oldname[1] == '|') { + ch = oldname[0]; + oldname += 2; + if (newname[0] && newname[1] == '|') { + if (newname[0] != ch) + // Both oldname and newname are fs specific but different ones. + return FALSE; + newname += 2; + } + } else { + ch = newname[0]; + newname += 2; + } + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == ch) + return p[0]->ren && p[0]->ren(oldname, newname); + } + return FALSE; + } + #endif + + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->ren && p[0]->ren(oldname,newname)) + return TRUE; + } + return FALSE; +} + +static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) { + // If we want write but the fs doesn't allow it then return + if ((f->flags & GFILEFLG_WRITE) && !(p->flags & GFSFLG_WRITEABLE)) + return FALSE; + + // Try to open + if (!p->open || !p->open(f, fname)) + return FALSE; + + // File is open - fill in all the details + f->vmt = p; + f->pos = 0; + f->flags |= GFILEFLG_OPEN; + if (p->flags & GFSFLG_SEEKABLE) + f->flags |= GFILEFLG_CANSEEK; + return TRUE; +} + +GFILE *gfileOpen(const char *fname, const char *mode) { + GFILE * f; + const GFILEVMT * const *p; + + // Get an empty file and set the flags + if (!(f = _gfileFindSlot(mode))) + return 0; + + #if GFILE_ALLOW_DEVICESPECIFIC + if (fname[0] && fname[1] == '|') { + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fname[0]) + return testopen(p[0], f, fname+2) ? f : 0; + } + + // File not found + return 0; + } + #endif + + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (testopen(p[0], f, fname)) + return f; + } + + // File not found + return 0; +} + +void gfileClose(GFILE *f) { + if (!f || !(f->flags & GFILEFLG_OPEN)) + return; + if (f->vmt->close) + f->vmt->close(f); + f->flags = 0; +} + +size_t gfileRead(GFILE *f, void *buf, size_t len) { + size_t res; + + if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_READ)) != (GFILEFLG_OPEN|GFILEFLG_READ)) + return 0; + if (!f->vmt->read) + return 0; + if ((res = f->vmt->read(f, buf, len)) <= 0) + return 0; + f->pos += res; + return res; +} + +size_t gfileWrite(GFILE *f, const void *buf, size_t len) { + size_t res; + + if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_WRITE)) != (GFILEFLG_OPEN|GFILEFLG_WRITE)) + return 0; + if (!f->vmt->write) + return 0; + if ((res = f->vmt->write(f, buf, len)) <= 0) + return 0; + f->pos += res; + return res; +} + +long int gfileGetPos(GFILE *f) { + if (!f || !(f->flags & GFILEFLG_OPEN)) + return 0; + return f->pos; +} + +bool_t gfileSetPos(GFILE *f, long int pos) { + if (!f || !(f->flags & GFILEFLG_OPEN)) + return FALSE; + if (!f->vmt->setpos || !f->vmt->setpos(f, pos)) + return FALSE; + f->pos = pos; + return TRUE; +} + +long int gfileGetSize(GFILE *f) { + if (!f || !(f->flags & GFILEFLG_OPEN)) + return 0; + if (!f->vmt->getsize) + return 0; + return f->vmt->getsize(f); +} + +bool_t gfileEOF(GFILE *f) { + if (!f || !(f->flags & GFILEFLG_OPEN)) + return TRUE; + if (!f->vmt->eof) + return FALSE; + return f->vmt->eof(f); +} + +bool_t gfileMount(char fs, const char* drive) { + const GFILEVMT * const *p; + + // Find the correct VMT + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fs) { + if (!p[0]->mount) + return FALSE; + return p[0]->mount(drive); + } + } + return FALSE; +} + +bool_t gfileUnmount(char fs, const char* drive) { + const GFILEVMT * const *p; + + // Find the correct VMT + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fs) { + if (!p[0]->mount) + return FALSE; + return p[0]->unmount(drive); + } + } + return FALSE; +} + +bool_t gfileSync(GFILE *f) { + if (!f->vmt->sync) + return FALSE; + return f->vmt->sync(f); +} + +#if GFILE_NEED_FILELISTS + gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs) { + const GFILEVMT * const *p; + gfileList * pfl; + + // Find the correct VMT + for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { + if (p[0]->prefix == fs) { + if (!p[0]->flopen) + return 0; + pfl = p[0]->flopen(path, dirs); + if (pfl) { + pfl->vmt = p[0]; + pfl->dirs = dirs; + } + return pfl; + } + } + return 0; + } + + const char *gfileReadFileList(gfileList *pfl) { + return pfl->vmt->flread ? pfl->vmt->flread(pfl) : 0; + } + + void gfileCloseFileList(gfileList *pfl) { + if (pfl->vmt->flclose) + pfl->vmt->flclose(pfl); + } +#endif + +#endif /* GFX_USE_GFILE */ diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h new file mode 100644 index 00000000..f332db4c --- /dev/null +++ b/src/gfile/gfile.h @@ -0,0 +1,470 @@ +/* + * 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 + */ + +/** + * @file src/gfile/gfile.h + * @brief GFILE - File IO Routines header file. + * + * @addtogroup GFILE + * + * @brief Module which contains Operating system independent FILEIO + * + * @{ + */ + +#ifndef _GFILE_H +#define _GFILE_H + +#include "gfx.h" + +#if GFX_USE_GFILE || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/** + * @brief A file pointer + */ + +typedef struct GFILE GFILE; +typedef struct gfileList gfileList; + +extern GFILE *gfileStdIn; +extern GFILE *gfileStdErr; +extern GFILE *gfileStdOut; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + + /** + * @brief Check if file exists + * + * @param[in] fname The file name + * + * @return TRUE if file exists, FALSE otherwise + * + * @api + */ + bool_t gfileExists(const char *fname); + + /** + * @brief Delete file + * + * @param[in] fname The file name + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileDelete(const char *fname); + + /** + * @brief Get the size of a file + * @note Please use @p gfileGetSize() if the file is opened + * + * @param[in] fname The file name + * + * @return File size on success, -1 on error + * + * @api + */ + long int gfileGetFilesize(const char *fname); + + /** + * @brief Rename file + * + * @param[in] oldname The current file name + * @param[in] newname The new name of the file + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileRename(const char *oldname, const char *newname); + + /** + * @brief Open file + * @details A file must be opened before it can be accessed + * @details The resulting GFILE will be used for all functions that access the file. + * + * @param[in] fname The file name + * @param[in] mode The mode. + * + * @return Valid GFILE on success, 0 otherwise + * + * @note The modes follow the c library fopen() standard. + * The valid modes are: + * + * The following flags can also be added to the above modes:
+ * + * @note Not all file-systems support all modes. For example, write + * is not available with the ROM file-system. Similarly few platforms + * distinguish between binary and text files. + * @note Even though binary vs. text is relevant only for a small number of platforms + * the "b" flag should always be specified for binary files such as images. + * This ensures portability to other platforms. The extra flag will be ignored + * on platforms where it is not relevant. + * + * @api + */ + GFILE * gfileOpen(const char *fname, const char *mode); + + /** + * @brief Close file + * @details Closes a file after is has been opened using @p gfileOpen() + * + * @param[in] f The file + * + * @api + */ + void gfileClose(GFILE *f); + + /** + * @brief Read from file + * @details Reads a given amount of bytes from the file + * @details The read/write cursor will not be reset when calling this function + * + * @param[in] f The file + * @param[out] buf The buffer in which to save the content that has been read from the file + * @param[in] len Amount of bytes to read + * + * @return Amount of bytes read + * + * @api + */ + size_t gfileRead(GFILE *f, void *buf, size_t len); + + /** + * @brief Write to file + * @details Write a given amount of bytes to the file + * @details The read/write cursor will not be reset when calling this function + * + * @param[in] f The file + * @param[in] buf The buffer which contains the content that will be written to the file + * @param[in] len Amount of bytes to write + * + * @return Amount of bytes written + * + * @api + */ + size_t gfileWrite(GFILE *f, const void *buf, size_t len); + + /** + * @brief Get the current position of the read/write cursor + * + * @param[in] f The file + * + * @return The current position in the file + * + * @api + */ + long int gfileGetPos(GFILE *f); + + /** + * @brief Set the position of the read/write cursor + * + * @param[in] f The file + * @param[in] pos The position to which the cursor will be set + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileSetPos(GFILE *f, long int pos); + + /** + * @brief Get the size of file + * @note Please use @p gfileGetFilesize() if the file is not opened + * + * @param[in] f The file + * + * @return The size of the file + * + * @api + */ + long int gfileGetSize(GFILE *f); + + /** + * @brief Check for EOF + * @details Checks if the cursor is at the end of the file + * + * @param[in] f The file + * + * @return TRUE if EOF, FALSE otherwise + * + * @api + */ + bool_t gfileEOF(GFILE *f); + + /** + * @brief Mount a logical drive (aka partition) + * + * @details Not supported by every file system + * @details Currently just one drive at one is supported. + * + * @param[in] fs The file system (F for FatFS) + * @param[in] drive The logical drive prefix + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileMount(char fs, const char *drive); + + /** + * @brief Unmount a logical drive (aka partition) + * + * @details Does have no effect if @p gfileMount() as been called before hand + * + * @param[in] fs The file system (F for FatFS) + * @param[in] drive The logical drive prefix + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileUnmount(char fs, const char *drive); + + /** + * @brief Syncs the file object (flushes the buffer) + * + * @details Not supported by every file system + * + * @param[in] f The file + * + * @return TRUE on success, FALSE otherwise + * + * @api + */ + bool_t gfileSync(GFILE *f); + + #if GFILE_NEED_FILELISTS || defined(__DOXYGEN__) + /** + * @brief Open a file list + * + * @param[in] fs The file system (F for FatFS) + * @param[in] path Path information to pass to the file system + * @param[in] dirs Pass TRUE to get directories only, FALSE to get files only + * + * @return A pointer to a file list on success, NULL otherwise + * + * @note The path parameter is handled in a file-system specific way. It could be + * treated as a directory name, it may be treated as a file pattern, or it + * may be ignored. Passing NULL will always return the full list of files + * in at least the top level directory. + * @note For file systems that do not support directories, passing TRUE for dirs + * will return an error. + * @note You must call @p gfileCloseFileList() when you have finished with the + * file list in order to free resources. + * + * @api + */ + gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs); + + /** + * @brief Get the next file in a file list. + * + * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() + * + * @return A pointer to a file (or directory) name. Returns NULL if there are no more. + * + * @note The file name may contain the full directory path or may not depending + * on how the file system treats directories. + * @note The returned buffer may be destroyed by the next call to any of + * @p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). + * Do not use this pointer after one of those calls. + * + * @api + */ + const char *gfileReadFileList(gfileList *pfl); + + /** + * @brief Close a file list. + * + * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() + * + * @api + */ + void gfileCloseFileList(gfileList *pfl); + #endif + + #if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__) + /** + * @brief Open file from a ChibiOS BaseFileStream + * + * @param[in] BaseFileStreamPtr The BaseFileStream to open as a GFILE + * @param[in] mode The mode. + * + * @return Valid GFILE on success, 0 otherwise + * + * @note The modes are the same modes as in @p gfileOpen(). The + * open mode is NOT compared against the BaseFileStream capabilities. + * @note Supported operations are: read, write, getpos, setpos, eof and getsize + * + * @api + */ + GFILE * gfileOpenBaseFileStream(void *BaseFileStreamPtr, const char *mode); + #endif + + #if GFILE_NEED_MEMFS || defined(__DOXYGEN__) + /** + * @brief Open file from a memory pointer + * + * @param[in] memptr The pointer to the memory + * @param[in] mode The mode. + * + * @return Valid GFILE on success, 0 otherwise + * + * @note The modes are the same modes as in @p gfileOpen(). Note there is + * no concept of file-size. Be careful not to overwrite other memory or + * to read from inaccessible sections of memory. + * @note Supported operations are: read, write, getpos, setpos + * + * @api + */ + GFILE * gfileOpenMemory(void *memptr, const char *mode); + #endif + + #if GFILE_NEED_STRINGS || defined(__DOXYGEN__) + /** + * @brief Open file from a null terminated C string + * + * @param[in] str The pointer to the string or string buffer + * @param[in] mode The mode + * + * @return Valid GFILE on success, 0 otherwise + * + * @note The modes are the same modes as in @p gfileOpen(). Note there is + * no concept of file-size. Be careful not to overwrite other memory or + * to read from inaccessible sections of memory. + * @note Reading will return EOF when the NULL character is reached. + * @note Writing will always place a NULL in the next character effectively terminating the + * string at the character just written. + * @note Supported operations are: read, write, append, getpos, setpos + * @note Be careful with setpos and getpos. They do not check for the end of the string. + * @note Reading and Writing will read/write a maximum of one character at a time. + * + * @api + */ + GFILE * gfileOpenString(char *str, const char *mode); + #endif + + #if GFILE_NEED_PRINTG || defined(__DOXYGEN__) + #include + + int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); + int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); + #define vfprintg(f,m,a) vfnprintg(f,0,m,a) + #define fprintg(f,m,...) fnprintg(f,0,m,...) + #define vprintg(m,a) vfnprintg(gfileStdOut,0,m,a) + #define printg(m,...) fnprintg(gfileStdOut,0,m,...) + + #if GFILE_NEED_STRINGS + int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); + int snprintg(char *buf, int maxlen, const char *fmt, ...); + #define vsprintg(s,m,a) vsnprintg(s,0,m,a) + #define sprintg(s,m,...) snprintg(s,0,m,...) + #endif + #endif + + #if GFILE_NEED_SCANG || defined(__DOXYGEN__) + #include + + int vfscang(GFILE *f, const char *fmt, va_list arg); + int fscang(GFILE *f, const char *fmt, ...); + #define vscang(f,a) vfscang(gfileStdIn,f,a) + #define scang(f,...) fscang(gfileStdIn,f,...) + + #if GFILE_NEED_STRINGS + int vsscang(const char *buf, const char *fmt, va_list arg); + int sscang(const char *buf, const char *fmt, ...); + #endif + #endif + + #if GFILE_NEED_STDIO && !defined(GFILE_IMPLEMENTATION) + #define stdin gfileStdIn + #define stdout gfileStdOut + #define stderr gfileStdErr + #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform + #define L_tmpnam FILENAME_MAX + #define FOPEN_MAX GFILE_MAX_GFILES + #define TMP_MAX GFILE_MAX_GFILES + #define P_tmpdir "/tmp/" + #define FILE GFILE + #define fopen(n,m) gfileOpen(n,m) + #define fclose(f) gfileClose(f) + size_t gstdioRead(void * ptr, size_t size, size_t count, FILE *f); + size_t gstdioWrite(const void * ptr, size_t size, size_t count, FILE *f); + #define fread(p,sz,cnt,f) gstdioRead(p,sz,cnt,f) + #define fwrite(p,sz,cnt,f) gstdioWrite(p,sz,cnt,f) + int gstdioSeek(FILE *f, size_t offset, int origin); + #define fseek(f,ofs,org) gstdioSeek(f,ofs,org) + #define SEEK_SET 0 + #define SEEK_CUR 1 + #define SEEK_END 2 + #define remove(n) (!gfileDelete(n)) + #define rename(o,n) (!gfileRename(o,n)) + #define fflush(f) (0) + #define ftell(f) gfileGetPos(f) + #define fpos_t long int + int gstdioGetpos(FILE *f, long int *pos); + #define fgetpos(f,pos) gstdioGetpos(f,pos) + #define fsetpos(f, pos) (!gfileSetPos(f, *pos)) + #define rewind(f) gfileSetPos(f, 0); + #define feof(f) gfileEOF(f) + + #define vfprintf(f,m,a) vfnprintg(f,0,m,a) + #define fprintf(f,m,...) fnprintg(f,0,m,...) + #define vprintf(m,a) vfnprintg(gfileStdOut,0,m,a) + #define printf(m,...) fnprintg(gfileStdOut,0,m,...) + #define vsnprintf(s,n,m,a) vsnprintg(s,n,m,a) + #define snprintf(s,n,m,...) snprintg(s,n,m,...) + #define vsprintf(s,m,a) vsnprintg(s,0,m,a) + #define sprintf(s,m,...) snprintg(s,0,m,...) + //TODO + //void clearerr ( FILE * stream ); + //int ferror ( FILE * stream ); + //FILE * tmpfile ( void ); // Auto-deleting + //char * tmpnam ( char * str ); + //char * mktemp (char *template); + //FILE * freopen ( const char * filename, const char * mode, FILE * stream ); + //setbuf + //setvbuf + //fflush + //fgetc + //fgets + //fputc + //fputs + //getc + //getchar + //puts + //ungetc + //void perror (const char * str); + #endif + +#ifdef __cplusplus +} +#endif + +#endif /* GFX_USE_GFILE */ + +#endif /* _GFILE_H */ +/** @} */ + diff --git a/src/gfile/gfile.mk b/src/gfile/gfile.mk new file mode 100644 index 00000000..8f20b5ce --- /dev/null +++ b/src/gfile/gfile.mk @@ -0,0 +1,18 @@ +GFXSRC += $(GFXLIB)/src/gfile/gfile.c \ + $(GFXLIB)/src/gfile/gfile_fs_native.c \ + $(GFXLIB)/src/gfile/gfile_fs_ram.c \ + $(GFXLIB)/src/gfile/gfile_fs_rom.c \ + $(GFXLIB)/src/gfile/gfile_fs_fatfs.c \ + $(GFXLIB)/src/gfile/gfile_fs_petitfs.c \ + $(GFXLIB)/src/gfile/gfile_fs_mem.c \ + $(GFXLIB)/src/gfile/gfile_fs_chibios.c \ + $(GFXLIB)/src/gfile/gfile_fs_strings.c \ + $(GFXLIB)/src/gfile/gfile_printg.c \ + $(GFXLIB)/src/gfile/gfile_scang.c \ + $(GFXLIB)/src/gfile/gfile_stdio.c \ + $(GFXLIB)/src/gfile/gfile_fatfs_wrapper.c \ + $(GFXLIB)/src/gfile/gfile_fatfs_diskio_chibios.c \ + $(GFXLIB)/src/gfile/gfile_petitfs_wrapper.c \ + $(GFXLIB)/src/gfile/gfile_petitfs_diskio_chibios.c \ + + \ No newline at end of file diff --git a/src/gfile/gfile_fatfs_diskio_chibios.c b/src/gfile/gfile_fatfs_diskio_chibios.c index 46ddbb7e..319d1a86 100644 --- a/src/gfile/gfile_fatfs_diskio_chibios.c +++ b/src/gfile/gfile_fatfs_diskio_chibios.c @@ -5,12 +5,6 @@ /* disk I/O modules and attach it to FatFs module with common interface. */ /*-----------------------------------------------------------------------*/ -/** - * @file src/gfile/gfile_fatfs_diskio_chibios.c - * @brief GFILE FATFS wrapper. - * - */ - #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_FATFS && GFX_USE_OS_CHIBIOS diff --git a/src/gfile/gfile_fatfs_wrapper.c b/src/gfile/gfile_fatfs_wrapper.c index edcab056..fb5e6ec2 100644 --- a/src/gfile/gfile_fatfs_wrapper.c +++ b/src/gfile/gfile_fatfs_wrapper.c @@ -5,12 +5,6 @@ * http://ugfx.org/license.html */ -/** - * @file src/gfile/gfile_fatfs_wrapper.c - * @brief GFILE FATFS wrapper. - * - */ - #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_FATFS diff --git a/src/gfile/gfile_gfile.c b/src/gfile/gfile_gfile.c deleted file mode 100644 index 3547f861..00000000 --- a/src/gfile/gfile_gfile.c +++ /dev/null @@ -1,407 +0,0 @@ -/* - * 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 - */ - -/** - * @file src/gfile/gfile_gfile.c - * @brief GFILE code. - * - */ - -#include "gfx.h" - -#if GFX_USE_GFILE - -#include "gfile_fs.h" - -/** - * Define the VMT's for the file-systems we want to search for files. - * Virtual file-systems that have special open() calls do not need to - * be in this list. - */ -#if GFILE_NEED_ROMFS - extern const GFILEVMT FsROMVMT; -#endif -#if GFILE_NEED_NATIVEFS - extern const GFILEVMT FsNativeVMT; -#endif -#if GFILE_NEED_FATFS - extern const GFILEVMT FsFatFSVMT; -#endif -#if GFILE_NEED_RAMFS - extern const GFILEVMT FsRAMVMT; -#endif - - -/** - * The order of the file-systems below determines the order - * that they are searched to find a file. - */ -static const GFILEVMT const * FsArray[] = { - #if GFILE_NEED_ROMFS - &FsROMVMT, - #endif - #if GFILE_NEED_NATIVEFS - &FsNativeVMT, - #endif - #if GFILE_NEED_FATFS - &FsFatFSVMT, - #endif - #if GFILE_NEED_RAMFS - &FsRAMVMT, - #endif -}; - -/* - * The table of GFILE's - */ -static GFILE gfileArr[GFILE_MAX_GFILES]; -GFILE *gfileStdIn; -GFILE *gfileStdOut; -GFILE *gfileStdErr; - -/** - * The init routine - */ -void _gfileInit(void) { - #if GFILE_NEED_NATIVEFS - extern void _gfileNativeAssignStdio(void); - _gfileNativeAssignStdio(); - #endif -} - -void _gfileDeinit(void) -{ - /* ToDo */ -} - -/** - * Internal routine to find an empty GFILE slot and interpret flags. - */ -GFILE *_gfileFindSlot(const char *mode) { - GFILE * f; - - // First find an available GFILE slot. - for (f = gfileArr; f < &gfileArr[GFILE_MAX_GFILES]; f++) { - if (!(f->flags & GFILEFLG_OPEN)) { - // Get the flags - switch(mode[0]) { - case 'r': - f->flags = GFILEFLG_READ|GFILEFLG_MUSTEXIST; - while (*++mode) { - switch(mode[0]) { - case '+': f->flags |= GFILEFLG_WRITE; break; - case 'b': f->flags |= GFILEFLG_BINARY; break; - } - } - break; - case 'w': - f->flags = GFILEFLG_WRITE|GFILEFLG_TRUNC; - while (*++mode) { - switch(mode[0]) { - case '+': f->flags |= GFILEFLG_READ; break; - case 'b': f->flags |= GFILEFLG_BINARY; break; - case 'x': f->flags |= GFILEFLG_MUSTNOTEXIST; break; - } - } - break; - case 'a': - f->flags = GFILEFLG_WRITE|GFILEFLG_APPEND; - while (*++mode) { - switch(mode[0]) { - case '+': f->flags |= GFILEFLG_READ; break; - case 'b': f->flags |= GFILEFLG_BINARY; break; - case 'x': f->flags |= GFILEFLG_MUSTNOTEXIST; break; - } - } - break; - default: - return 0; - } - return f; - } - } - return 0; -} - -/******************************************************** - * IO routines - ********************************************************/ - -bool_t gfileExists(const char *fname) { - const GFILEVMT * const *p; - - #if GFILE_ALLOW_DEVICESPECIFIC - if (fname[0] && fname[1] == '|') { - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fname[0]) - return p[0]->exists && p[0]->exists(fname+2); - } - return FALSE; - } - #endif - - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->exists && p[0]->exists(fname)) - return TRUE; - } - return FALSE; -} - -bool_t gfileDelete(const char *fname) { - const GFILEVMT **p; - - #if GFILE_ALLOW_DEVICESPECIFIC - if (fname[0] && fname[1] == '|') { - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fname[0]) - return p[0]->del && p[0]->del(fname+2); - } - return FALSE; - } - #endif - - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->del && p[0]->del(fname)) - return TRUE; - } - return FALSE; -} - -long int gfileGetFilesize(const char *fname) { - const GFILEVMT * const *p; - long int res; - - #if GFILE_ALLOW_DEVICESPECIFIC - if (fname[0] && fname[1] == '|') { - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fname[0]) - return p[0]->filesize ? p[0]->filesize(fname+2) : -1; - } - return -1; - } - #endif - - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->filesize && (res = p[0]->filesize(fname)) != -1) - return res; - } - return -1; -} - -bool_t gfileRename(const char *oldname, const char *newname) { - const GFILEVMT * const *p; - - #if GFILE_ALLOW_DEVICESPECIFIC - if ((oldname[0] && oldname[1] == '|') || (newname[0] && newname[1] == '|')) { - char ch; - - if (oldname[0] && oldname[1] == '|') { - ch = oldname[0]; - oldname += 2; - if (newname[0] && newname[1] == '|') { - if (newname[0] != ch) - // Both oldname and newname are fs specific but different ones. - return FALSE; - newname += 2; - } - } else { - ch = newname[0]; - newname += 2; - } - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == ch) - return p[0]->ren && p[0]->ren(oldname, newname); - } - return FALSE; - } - #endif - - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->ren && p[0]->ren(oldname,newname)) - return TRUE; - } - return FALSE; -} - -static bool_t testopen(const GFILEVMT *p, GFILE *f, const char *fname) { - // If we want write but the fs doesn't allow it then return - if ((f->flags & GFILEFLG_WRITE) && !(p->flags & GFSFLG_WRITEABLE)) - return FALSE; - - // Try to open - if (!p->open || !p->open(f, fname)) - return FALSE; - - // File is open - fill in all the details - f->vmt = p; - f->pos = 0; - f->flags |= GFILEFLG_OPEN; - if (p->flags & GFSFLG_SEEKABLE) - f->flags |= GFILEFLG_CANSEEK; - return TRUE; -} - -GFILE *gfileOpen(const char *fname, const char *mode) { - GFILE * f; - const GFILEVMT * const *p; - - // Get an empty file and set the flags - if (!(f = _gfileFindSlot(mode))) - return 0; - - #if GFILE_ALLOW_DEVICESPECIFIC - if (fname[0] && fname[1] == '|') { - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fname[0]) - return testopen(p[0], f, fname+2) ? f : 0; - } - - // File not found - return 0; - } - #endif - - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (testopen(p[0], f, fname)) - return f; - } - - // File not found - return 0; -} - -void gfileClose(GFILE *f) { - if (!f || !(f->flags & GFILEFLG_OPEN)) - return; - if (f->vmt->close) - f->vmt->close(f); - f->flags = 0; -} - -size_t gfileRead(GFILE *f, void *buf, size_t len) { - size_t res; - - if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_READ)) != (GFILEFLG_OPEN|GFILEFLG_READ)) - return 0; - if (!f->vmt->read) - return 0; - if ((res = f->vmt->read(f, buf, len)) <= 0) - return 0; - f->pos += res; - return res; -} - -size_t gfileWrite(GFILE *f, const void *buf, size_t len) { - size_t res; - - if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_WRITE)) != (GFILEFLG_OPEN|GFILEFLG_WRITE)) - return 0; - if (!f->vmt->write) - return 0; - if ((res = f->vmt->write(f, buf, len)) <= 0) - return 0; - f->pos += res; - return res; -} - -long int gfileGetPos(GFILE *f) { - if (!f || !(f->flags & GFILEFLG_OPEN)) - return 0; - return f->pos; -} - -bool_t gfileSetPos(GFILE *f, long int pos) { - if (!f || !(f->flags & GFILEFLG_OPEN)) - return FALSE; - if (!f->vmt->setpos || !f->vmt->setpos(f, pos)) - return FALSE; - f->pos = pos; - return TRUE; -} - -long int gfileGetSize(GFILE *f) { - if (!f || !(f->flags & GFILEFLG_OPEN)) - return 0; - if (!f->vmt->getsize) - return 0; - return f->vmt->getsize(f); -} - -bool_t gfileEOF(GFILE *f) { - if (!f || !(f->flags & GFILEFLG_OPEN)) - return TRUE; - if (!f->vmt->eof) - return FALSE; - return f->vmt->eof(f); -} - -bool_t gfileMount(char fs, const char* drive) { - const GFILEVMT * const *p; - - // Find the correct VMT - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fs) { - if (!p[0]->mount) - return FALSE; - return p[0]->mount(drive); - } - } - return FALSE; -} - -bool_t gfileUnmount(char fs, const char* drive) { - const GFILEVMT * const *p; - - // Find the correct VMT - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fs) { - if (!p[0]->mount) - return FALSE; - return p[0]->unmount(drive); - } - } - return FALSE; -} - -bool_t gfileSync(GFILE *f) { - if (!f->vmt->sync) - return FALSE; - return f->vmt->sync(f); -} - -#if GFILE_NEED_FILELISTS - gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs) { - const GFILEVMT * const *p; - gfileList * pfl; - - // Find the correct VMT - for(p = FsArray; p < &FsArray[sizeof(FsArray)/sizeof(FsArray[0])]; p++) { - if (p[0]->prefix == fs) { - if (!p[0]->flopen) - return 0; - pfl = p[0]->flopen(path, dirs); - if (pfl) { - pfl->vmt = p[0]; - pfl->dirs = dirs; - } - return pfl; - } - } - return 0; - } - - const char *gfileReadFileList(gfileList *pfl) { - return pfl->vmt->flread ? pfl->vmt->flread(pfl) : 0; - } - - void gfileCloseFileList(gfileList *pfl) { - if (pfl->vmt->flclose) - pfl->vmt->flclose(pfl); - } -#endif - -#endif /* GFX_USE_GFILE */ diff --git a/src/gfile/gfile_options.h b/src/gfile/gfile_options.h new file mode 100644 index 00000000..06781f38 --- /dev/null +++ b/src/gfile/gfile_options.h @@ -0,0 +1,207 @@ +/* + * 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 + */ + +/** + * @file src/gfile/gfile_options.h + * @brief GFILE - File IO options header file. + * + * @addtogroup GFILE + * @{ + */ + +#ifndef _GFILE_OPTIONS_H +#define _GFILE_OPTIONS_H + +/** + * @name GFILE Functionality to be included + * @{ + */ + /** + * @brief Should the filesystem not be mounted automatically + * @details The filesystem is normally mounted automatically if the + * user does not do it manually. This option turns that off + * so the user must manually mount the file-system first. + * @details Defaults to FALSE + */ + #ifndef GFILE_NEED_NOAUTOMOUNT + #define GFILE_NEED_NOAUTOMOUNT FALSE + #endif + /** + * @brief Should the filesystem be synced automatically + * @details The filesystem will automatically be synced after an open() or + * write() call unless this feature is disabled. + * @details If this feature is disabled, the user should sync the filesystem + * himself using @p gfileSync() + * @details Not all filesystems implement the syncing feature. This feature will + * have no effect in such a case. + * @details Defaults to FALSE + */ + #ifndef GFILE_NEED_NOAUTOSYNC + #define GFILE_NEED_NOAUTOSYNC FALSE + #endif + /** + * @brief Include printg, fprintg etc functions + * @details Defaults to FALSE + * @pre To get the string sprintg functions you also need to define @p GFILE_NEED_STRINGS + */ + #ifndef GFILE_NEED_PRINTG + #define GFILE_NEED_PRINTG FALSE + #endif + /** + * @brief Include scang, fscang etc functions + * @details Defaults to FALSE + * @pre To get the string sscang functions you also need to define @p GFILE_NEED_STRINGS + */ + #ifndef GFILE_NEED_SCANG + #define GFILE_NEED_SCANG FALSE + #endif + /** + * @brief Include the string based file functions + * @details Defaults to FALSE + */ + #ifndef GFILE_NEED_STRINGS + #define GFILE_NEED_STRINGS FALSE + #endif + /** + * @brief Map many stdio functions to their GFILE equivalent + * @details Defaults to FALSE + * @note This replaces the functions in stdio.h with equivalents + * - Do not include stdio.h as it has different conflicting definitions. + */ + #ifndef GFILE_NEED_STDIO + #define GFILE_NEED_STDIO FALSE + #endif + /** + * @brief Include the ROM file system + * @details Defaults to FALSE + * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are + * opening a file on the ROM file system by prefixing + * its name with "S|" (the letter 'S', followed by a vertical bar). + * @note This requires a file called romfs_files.h to be in the + * users project include path. This file should include all the files + * converted to .h files using the file2c utility (using flags "-dbcs"). + */ + #ifndef GFILE_NEED_ROMFS + #define GFILE_NEED_ROMFS FALSE + #endif + /** + * @brief Include the RAM file system + * @details Defaults to FALSE + * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are + * opening a file on the RAM file system by prefixing + * its name with "R|" (the letter 'R', followed by a vertical bar). + * @note You must also define GFILE_RAMFS_SIZE with the size of the file system + * to be allocated in RAM. + */ + #ifndef GFILE_NEED_RAMFS + #define GFILE_NEED_RAMFS FALSE + #endif + /** + * @brief Include the FAT file system driver based on the FATFS library + * @details Defaults to FALSE + * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are + * opening a file on the FAT file system by prefixing + * its name with "F|" (the letter 'F', followed by a vertical bar). + * @note FATFS and PETITFS offer the same FAT file system support. They just use + * different constraints. PETITFS is smaller but has less features. Only + * one can be used at a time. The block interfaces are also different. + */ + #ifndef GFILE_NEED_FATFS + #define GFILE_NEED_FATFS FALSE + #endif + /** + * @brief Include the FAT file system driver based on the PETITFS library + * @details Defaults to FALSE + * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are + * opening a file on the FAT file system by prefixing + * its name with "F|" (the letter 'F', followed by a vertical bar). + * @note FATFS and PETITFS offer the same FAT file system support. They just use + * different constraints. PETITFS is smaller but has less features. Only + * one can be used at a time. The block interfaces are also different. + * @note Due to the restrictions on the PETITFS library on writing, we do not implement + * writing. + * @note PETITFS can only have one file open at a time. + */ + #ifndef GFILE_NEED_PETITFS + #define GFILE_NEED_PETITFS FALSE + #endif + /** + * @brief Include the operating system's native file system + * @details Defaults to FALSE + * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are + * opening a file on the native file system by prefixing + * its name with "N|" (the letter 'N', followed by a vertical bar). + * @note If defined then the gfileStdOut and gfileStdErr handles + * use the operating system equivalent stdio and stderr. + * If it is not defined the gfileStdOut and gfileStdErr io is discarded. + */ + #ifndef GFILE_NEED_NATIVEFS + #define GFILE_NEED_NATIVEFS FALSE + #endif + /** + * @brief Include ChibiOS BaseFileStream support + * @details Defaults to FALSE + * @pre This is only relevant on the ChibiOS operating system. + * @note Use the @p gfileOpenBaseFileStream() call to open a GFILE based on a + * BaseFileStream. The BaseFileStream must already be open. + * @note A GFile of this type cannot be opened by filename. The BaseFileStream + * must be pre-opened using the operating system. + */ + #ifndef GFILE_NEED_CHIBIOSFS + #define GFILE_NEED_CHIBIOSFS FALSE + #endif + /** + * @brief Include raw memory pointer support + * @details Defaults to FALSE + * @note Use the @p gfileOpenMemory() call to open a GFILE based on a + * memory pointer. The GFILE opened appears to be of unlimited size. + * @note A GFile of this type cannot be opened by filename. + */ + #ifndef GFILE_NEED_MEMFS + #define GFILE_NEED_MEMFS FALSE + #endif + /** + * @brief Include support for file list functions + * @details Defaults to FALSE + * @note Adds support for @p gfileOpenFileList(), @p gfileReadFileList() and @p gfileCloseFileList(). + */ + #ifndef GFILE_NEED_FILELISTS + #define GFILE_NEED_FILELISTS FALSE + #endif +/** + * @} + * + * @name GFILE Optional Parameters + * @{ + */ + /** + * @brief Add floating point support to printg/scang etc. + */ + #ifndef GFILE_ALLOW_FLOATS + #define GFILE_ALLOW_FLOATS FALSE + #endif + /** + * @brief Can the device be specified as part of the file name. + * @note If this is on then a device letter and a vertical bar can be + * prefixed on a file name to specify that it must be on a + * specific device. + */ + #ifndef GFILE_ALLOW_DEVICESPECIFIC + #define GFILE_ALLOW_DEVICESPECIFIC FALSE + #endif + /** + * @brief The maximum number of open files + * @note This count excludes gfileStdIn, gfileStdOut and gfileStdErr + * (if open by default). + */ + #ifndef GFILE_MAX_GFILES + #define GFILE_MAX_GFILES 3 + #endif +/** @} */ + +#endif /* _GFILE_OPTIONS_H */ +/** @} */ diff --git a/src/gfile/gfile_petitfs_diskio_chibios.c b/src/gfile/gfile_petitfs_diskio_chibios.c index 90e709e4..7aa236ba 100644 --- a/src/gfile/gfile_petitfs_diskio_chibios.c +++ b/src/gfile/gfile_petitfs_diskio_chibios.c @@ -5,12 +5,6 @@ /* disk I/O modules and attach it to FatFs module with common interface. */ /*-----------------------------------------------------------------------*/ -/** - * @file src/gfile/gfile_petitfs_diskio_chibios.c - * @brief GFILE FATFS wrapper. - * - */ - #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_PETITFS && GFX_USE_OS_CHIBIOS diff --git a/src/gfile/gfile_petitfs_wrapper.c b/src/gfile/gfile_petitfs_wrapper.c index 8efc7eb9..b7bc0ee1 100644 --- a/src/gfile/gfile_petitfs_wrapper.c +++ b/src/gfile/gfile_petitfs_wrapper.c @@ -5,12 +5,6 @@ * http://ugfx.org/license.html */ -/** - * @file src/gfile/gfile_petitfs_wrapper.c - * @brief GFILE PETITFS wrapper. - * - */ - #include "gfx.h" #if GFX_USE_GFILE && GFILE_NEED_PETITFS diff --git a/src/gfile/gfile_rules.h b/src/gfile/gfile_rules.h new file mode 100644 index 00000000..949a500c --- /dev/null +++ b/src/gfile/gfile_rules.h @@ -0,0 +1,26 @@ +/* + * 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 + */ + +/** + * @file src/gfile/gfile_rules.h + * @brief GFILE safety rules header file. + * + * @addtogroup GFILE + * @{ + */ + +#ifndef _GFILE_RULES_H +#define _GFILE_RULES_H + +#if GFX_USE_GFILE + #if GFILE_NEED_PETITFS && GFILE_NEED_FATFS + #error "GFILE: Both GFILE_NEED_PETITFS and GFILE_NEED_FATFS cannot both be turned on at the same time." + #endif +#endif + +#endif /* _GFILE_RULES_H */ +/** @} */ diff --git a/src/gfile/sys_defs.h b/src/gfile/sys_defs.h deleted file mode 100644 index 2c475b40..00000000 --- a/src/gfile/sys_defs.h +++ /dev/null @@ -1,470 +0,0 @@ -/* - * 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 - */ - -/** - * @file src/gfile/sys_defs.h - * @brief GFILE - File IO Routines header file. - * - * @addtogroup GFILE - * - * @brief Module which contains Operating system independent FILEIO - * - * @{ - */ - -#ifndef _GFILE_H -#define _GFILE_H - -#include "gfx.h" - -#if GFX_USE_GFILE || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Type definitions */ -/*===========================================================================*/ - -/** - * @brief A file pointer - */ - -typedef struct GFILE GFILE; -typedef struct gfileList gfileList; - -extern GFILE *gfileStdIn; -extern GFILE *gfileStdErr; -extern GFILE *gfileStdOut; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - - /** - * @brief Check if file exists - * - * @param[in] fname The file name - * - * @return TRUE if file exists, FALSE otherwise - * - * @api - */ - bool_t gfileExists(const char *fname); - - /** - * @brief Delete file - * - * @param[in] fname The file name - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileDelete(const char *fname); - - /** - * @brief Get the size of a file - * @note Please use @p gfileGetSize() if the file is opened - * - * @param[in] fname The file name - * - * @return File size on success, -1 on error - * - * @api - */ - long int gfileGetFilesize(const char *fname); - - /** - * @brief Rename file - * - * @param[in] oldname The current file name - * @param[in] newname The new name of the file - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileRename(const char *oldname, const char *newname); - - /** - * @brief Open file - * @details A file must be opened before it can be accessed - * @details The resulting GFILE will be used for all functions that access the file. - * - * @param[in] fname The file name - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes follow the c library fopen() standard. - * The valid modes are: - *
  • r - Open for read, the file must exist
  • - *
  • w - Open for write, the file is truncated if it exists
  • - *
  • wx - Open for write, the file must not exist
  • - *
  • a - Open for append, the file is truncated if it exists
  • - *
  • ax - Open for append, the file must not exists
  • - *
- * The following flags can also be added to the above modes:
- *
  • + - Open for both read and write
  • - *
  • b - Open as a binary file rather than a text file
  • - *
- * @note Not all file-systems support all modes. For example, write - * is not available with the ROM file-system. Similarly few platforms - * distinguish between binary and text files. - * @note Even though binary vs. text is relevant only for a small number of platforms - * the "b" flag should always be specified for binary files such as images. - * This ensures portability to other platforms. The extra flag will be ignored - * on platforms where it is not relevant. - * - * @api - */ - GFILE * gfileOpen(const char *fname, const char *mode); - - /** - * @brief Close file - * @details Closes a file after is has been opened using @p gfileOpen() - * - * @param[in] f The file - * - * @api - */ - void gfileClose(GFILE *f); - - /** - * @brief Read from file - * @details Reads a given amount of bytes from the file - * @details The read/write cursor will not be reset when calling this function - * - * @param[in] f The file - * @param[out] buf The buffer in which to save the content that has been read from the file - * @param[in] len Amount of bytes to read - * - * @return Amount of bytes read - * - * @api - */ - size_t gfileRead(GFILE *f, void *buf, size_t len); - - /** - * @brief Write to file - * @details Write a given amount of bytes to the file - * @details The read/write cursor will not be reset when calling this function - * - * @param[in] f The file - * @param[in] buf The buffer which contains the content that will be written to the file - * @param[in] len Amount of bytes to write - * - * @return Amount of bytes written - * - * @api - */ - size_t gfileWrite(GFILE *f, const void *buf, size_t len); - - /** - * @brief Get the current position of the read/write cursor - * - * @param[in] f The file - * - * @return The current position in the file - * - * @api - */ - long int gfileGetPos(GFILE *f); - - /** - * @brief Set the position of the read/write cursor - * - * @param[in] f The file - * @param[in] pos The position to which the cursor will be set - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileSetPos(GFILE *f, long int pos); - - /** - * @brief Get the size of file - * @note Please use @p gfileGetFilesize() if the file is not opened - * - * @param[in] f The file - * - * @return The size of the file - * - * @api - */ - long int gfileGetSize(GFILE *f); - - /** - * @brief Check for EOF - * @details Checks if the cursor is at the end of the file - * - * @param[in] f The file - * - * @return TRUE if EOF, FALSE otherwise - * - * @api - */ - bool_t gfileEOF(GFILE *f); - - /** - * @brief Mount a logical drive (aka partition) - * - * @details Not supported by every file system - * @details Currently just one drive at one is supported. - * - * @param[in] fs The file system (F for FatFS) - * @param[in] drive The logical drive prefix - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileMount(char fs, const char *drive); - - /** - * @brief Unmount a logical drive (aka partition) - * - * @details Does have no effect if @p gfileMount() as been called before hand - * - * @param[in] fs The file system (F for FatFS) - * @param[in] drive The logical drive prefix - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileUnmount(char fs, const char *drive); - - /** - * @brief Syncs the file object (flushes the buffer) - * - * @details Not supported by every file system - * - * @param[in] f The file - * - * @return TRUE on success, FALSE otherwise - * - * @api - */ - bool_t gfileSync(GFILE *f); - - #if GFILE_NEED_FILELISTS || defined(__DOXYGEN__) - /** - * @brief Open a file list - * - * @param[in] fs The file system (F for FatFS) - * @param[in] path Path information to pass to the file system - * @param[in] dirs Pass TRUE to get directories only, FALSE to get files only - * - * @return A pointer to a file list on success, NULL otherwise - * - * @note The path parameter is handled in a file-system specific way. It could be - * treated as a directory name, it may be treated as a file pattern, or it - * may be ignored. Passing NULL will always return the full list of files - * in at least the top level directory. - * @note For file systems that do not support directories, passing TRUE for dirs - * will return an error. - * @note You must call @p gfileCloseFileList() when you have finished with the - * file list in order to free resources. - * - * @api - */ - gfileList *gfileOpenFileList(char fs, const char *path, bool_t dirs); - - /** - * @brief Get the next file in a file list. - * - * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() - * - * @return A pointer to a file (or directory) name. Returns NULL if there are no more. - * - * @note The file name may contain the full directory path or may not depending - * on how the file system treats directories. - * @note The returned buffer may be destroyed by the next call to any of - * @p gfileOpenFileList(), @p gfileReadFileList() or @p gfileCloseFileList(). - * Do not use this pointer after one of those calls. - * - * @api - */ - const char *gfileReadFileList(gfileList *pfl); - - /** - * @brief Close a file list. - * - * @param[in] pfl Pointer to a file list returned by @p gfileOpenFileList() - * - * @api - */ - void gfileCloseFileList(gfileList *pfl); - #endif - - #if (GFILE_NEED_CHIBIOSFS && GFX_USE_OS_CHIBIOS) || defined(__DOXYGEN__) - /** - * @brief Open file from a ChibiOS BaseFileStream - * - * @param[in] BaseFileStreamPtr The BaseFileStream to open as a GFILE - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). The - * open mode is NOT compared against the BaseFileStream capabilities. - * @note Supported operations are: read, write, getpos, setpos, eof and getsize - * - * @api - */ - GFILE * gfileOpenBaseFileStream(void *BaseFileStreamPtr, const char *mode); - #endif - - #if GFILE_NEED_MEMFS || defined(__DOXYGEN__) - /** - * @brief Open file from a memory pointer - * - * @param[in] memptr The pointer to the memory - * @param[in] mode The mode. - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). Note there is - * no concept of file-size. Be careful not to overwrite other memory or - * to read from inaccessible sections of memory. - * @note Supported operations are: read, write, getpos, setpos - * - * @api - */ - GFILE * gfileOpenMemory(void *memptr, const char *mode); - #endif - - #if GFILE_NEED_STRINGS || defined(__DOXYGEN__) - /** - * @brief Open file from a null terminated C string - * - * @param[in] str The pointer to the string or string buffer - * @param[in] mode The mode - * - * @return Valid GFILE on success, 0 otherwise - * - * @note The modes are the same modes as in @p gfileOpen(). Note there is - * no concept of file-size. Be careful not to overwrite other memory or - * to read from inaccessible sections of memory. - * @note Reading will return EOF when the NULL character is reached. - * @note Writing will always place a NULL in the next character effectively terminating the - * string at the character just written. - * @note Supported operations are: read, write, append, getpos, setpos - * @note Be careful with setpos and getpos. They do not check for the end of the string. - * @note Reading and Writing will read/write a maximum of one character at a time. - * - * @api - */ - GFILE * gfileOpenString(char *str, const char *mode); - #endif - - #if GFILE_NEED_PRINTG || defined(__DOXYGEN__) - #include - - int vfnprintg(GFILE *f, int maxlen, const char *fmt, va_list arg); - int fnprintg(GFILE *f, int maxlen, const char *fmt, ...); - #define vfprintg(f,m,a) vfnprintg(f,0,m,a) - #define fprintg(f,m,...) fnprintg(f,0,m,...) - #define vprintg(m,a) vfnprintg(gfileStdOut,0,m,a) - #define printg(m,...) fnprintg(gfileStdOut,0,m,...) - - #if GFILE_NEED_STRINGS - int vsnprintg(char *buf, int maxlen, const char *fmt, va_list arg); - int snprintg(char *buf, int maxlen, const char *fmt, ...); - #define vsprintg(s,m,a) vsnprintg(s,0,m,a) - #define sprintg(s,m,...) snprintg(s,0,m,...) - #endif - #endif - - #if GFILE_NEED_SCANG || defined(__DOXYGEN__) - #include - - int vfscang(GFILE *f, const char *fmt, va_list arg); - int fscang(GFILE *f, const char *fmt, ...); - #define vscang(f,a) vfscang(gfileStdIn,f,a) - #define scang(f,...) fscang(gfileStdIn,f,...) - - #if GFILE_NEED_STRINGS - int vsscang(const char *buf, const char *fmt, va_list arg); - int sscang(const char *buf, const char *fmt, ...); - #endif - #endif - - #if GFILE_NEED_STDIO && !defined(GFILE_IMPLEMENTATION) - #define stdin gfileStdIn - #define stdout gfileStdOut - #define stderr gfileStdErr - #define FILENAME_MAX 256 // Use a relatively small number for an embedded platform - #define L_tmpnam FILENAME_MAX - #define FOPEN_MAX GFILE_MAX_GFILES - #define TMP_MAX GFILE_MAX_GFILES - #define P_tmpdir "/tmp/" - #define FILE GFILE - #define fopen(n,m) gfileOpen(n,m) - #define fclose(f) gfileClose(f) - size_t gstdioRead(void * ptr, size_t size, size_t count, FILE *f); - size_t gstdioWrite(const void * ptr, size_t size, size_t count, FILE *f); - #define fread(p,sz,cnt,f) gstdioRead(p,sz,cnt,f) - #define fwrite(p,sz,cnt,f) gstdioWrite(p,sz,cnt,f) - int gstdioSeek(FILE *f, size_t offset, int origin); - #define fseek(f,ofs,org) gstdioSeek(f,ofs,org) - #define SEEK_SET 0 - #define SEEK_CUR 1 - #define SEEK_END 2 - #define remove(n) (!gfileDelete(n)) - #define rename(o,n) (!gfileRename(o,n)) - #define fflush(f) (0) - #define ftell(f) gfileGetPos(f) - #define fpos_t long int - int gstdioGetpos(FILE *f, long int *pos); - #define fgetpos(f,pos) gstdioGetpos(f,pos) - #define fsetpos(f, pos) (!gfileSetPos(f, *pos)) - #define rewind(f) gfileSetPos(f, 0); - #define feof(f) gfileEOF(f) - - #define vfprintf(f,m,a) vfnprintg(f,0,m,a) - #define fprintf(f,m,...) fnprintg(f,0,m,...) - #define vprintf(m,a) vfnprintg(gfileStdOut,0,m,a) - #define printf(m,...) fnprintg(gfileStdOut,0,m,...) - #define vsnprintf(s,n,m,a) vsnprintg(s,n,m,a) - #define snprintf(s,n,m,...) snprintg(s,n,m,...) - #define vsprintf(s,m,a) vsnprintg(s,0,m,a) - #define sprintf(s,m,...) snprintg(s,0,m,...) - //TODO - //void clearerr ( FILE * stream ); - //int ferror ( FILE * stream ); - //FILE * tmpfile ( void ); // Auto-deleting - //char * tmpnam ( char * str ); - //char * mktemp (char *template); - //FILE * freopen ( const char * filename, const char * mode, FILE * stream ); - //setbuf - //setvbuf - //fflush - //fgetc - //fgets - //fputc - //fputs - //getc - //getchar - //puts - //ungetc - //void perror (const char * str); - #endif - -#ifdef __cplusplus -} -#endif - -#endif /* GFX_USE_GFILE */ - -#endif /* _GFILE_H */ -/** @} */ - diff --git a/src/gfile/sys_make.mk b/src/gfile/sys_make.mk deleted file mode 100644 index 0a85d1ae..00000000 --- a/src/gfile/sys_make.mk +++ /dev/null @@ -1,18 +0,0 @@ -GFXSRC += $(GFXLIB)/src/gfile/gfile_gfile.c \ - $(GFXLIB)/src/gfile/gfile_fs_native.c \ - $(GFXLIB)/src/gfile/gfile_fs_ram.c \ - $(GFXLIB)/src/gfile/gfile_fs_rom.c \ - $(GFXLIB)/src/gfile/gfile_fs_fatfs.c \ - $(GFXLIB)/src/gfile/gfile_fs_petitfs.c \ - $(GFXLIB)/src/gfile/gfile_fs_mem.c \ - $(GFXLIB)/src/gfile/gfile_fs_chibios.c \ - $(GFXLIB)/src/gfile/gfile_fs_strings.c \ - $(GFXLIB)/src/gfile/gfile_printg.c \ - $(GFXLIB)/src/gfile/gfile_scang.c \ - $(GFXLIB)/src/gfile/gfile_stdio.c \ - $(GFXLIB)/src/gfile/gfile_fatfs_wrapper.c \ - $(GFXLIB)/src/gfile/gfile_fatfs_diskio_chibios.c \ - $(GFXLIB)/src/gfile/gfile_petitfs_wrapper.c \ - $(GFXLIB)/src/gfile/gfile_petitfs_diskio_chibios.c \ - - \ No newline at end of file diff --git a/src/gfile/sys_options.h b/src/gfile/sys_options.h deleted file mode 100644 index 5581b13b..00000000 --- a/src/gfile/sys_options.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - * 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 - */ - -/** - * @file src/gfile/sys_options.h - * @brief GFILE - File IO options header file. - * - * @addtogroup GFILE - * @{ - */ - -#ifndef _GFILE_OPTIONS_H -#define _GFILE_OPTIONS_H - -/** - * @name GFILE Functionality to be included - * @{ - */ - /** - * @brief Should the filesystem not be mounted automatically - * @details The filesystem is normally mounted automatically if the - * user does not do it manually. This option turns that off - * so the user must manually mount the file-system first. - * @details Defaults to FALSE - */ - #ifndef GFILE_NEED_NOAUTOMOUNT - #define GFILE_NEED_NOAUTOMOUNT FALSE - #endif - /** - * @brief Should the filesystem be synced automatically - * @details The filesystem will automatically be synced after an open() or - * write() call unless this feature is disabled. - * @details If this feature is disabled, the user should sync the filesystem - * himself using @p gfileSync() - * @details Not all filesystems implement the syncing feature. This feature will - * have no effect in such a case. - * @details Defaults to FALSE - */ - #ifndef GFILE_NEED_NOAUTOSYNC - #define GFILE_NEED_NOAUTOSYNC FALSE - #endif - /** - * @brief Include printg, fprintg etc functions - * @details Defaults to FALSE - * @pre To get the string sprintg functions you also need to define @p GFILE_NEED_STRINGS - */ - #ifndef GFILE_NEED_PRINTG - #define GFILE_NEED_PRINTG FALSE - #endif - /** - * @brief Include scang, fscang etc functions - * @details Defaults to FALSE - * @pre To get the string sscang functions you also need to define @p GFILE_NEED_STRINGS - */ - #ifndef GFILE_NEED_SCANG - #define GFILE_NEED_SCANG FALSE - #endif - /** - * @brief Include the string based file functions - * @details Defaults to FALSE - */ - #ifndef GFILE_NEED_STRINGS - #define GFILE_NEED_STRINGS FALSE - #endif - /** - * @brief Map many stdio functions to their GFILE equivalent - * @details Defaults to FALSE - * @note This replaces the functions in stdio.h with equivalents - * - Do not include stdio.h as it has different conflicting definitions. - */ - #ifndef GFILE_NEED_STDIO - #define GFILE_NEED_STDIO FALSE - #endif - /** - * @brief Include the ROM file system - * @details Defaults to FALSE - * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are - * opening a file on the ROM file system by prefixing - * its name with "S|" (the letter 'S', followed by a vertical bar). - * @note This requires a file called romfs_files.h to be in the - * users project include path. This file should include all the files - * converted to .h files using the file2c utility (using flags "-dbcs"). - */ - #ifndef GFILE_NEED_ROMFS - #define GFILE_NEED_ROMFS FALSE - #endif - /** - * @brief Include the RAM file system - * @details Defaults to FALSE - * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are - * opening a file on the RAM file system by prefixing - * its name with "R|" (the letter 'R', followed by a vertical bar). - * @note You must also define GFILE_RAMFS_SIZE with the size of the file system - * to be allocated in RAM. - */ - #ifndef GFILE_NEED_RAMFS - #define GFILE_NEED_RAMFS FALSE - #endif - /** - * @brief Include the FAT file system driver based on the FATFS library - * @details Defaults to FALSE - * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are - * opening a file on the FAT file system by prefixing - * its name with "F|" (the letter 'F', followed by a vertical bar). - * @note FATFS and PETITFS offer the same FAT file system support. They just use - * different constraints. PETITFS is smaller but has less features. Only - * one can be used at a time. The block interfaces are also different. - */ - #ifndef GFILE_NEED_FATFS - #define GFILE_NEED_FATFS FALSE - #endif - /** - * @brief Include the FAT file system driver based on the PETITFS library - * @details Defaults to FALSE - * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are - * opening a file on the FAT file system by prefixing - * its name with "F|" (the letter 'F', followed by a vertical bar). - * @note FATFS and PETITFS offer the same FAT file system support. They just use - * different constraints. PETITFS is smaller but has less features. Only - * one can be used at a time. The block interfaces are also different. - * @note Due to the restrictions on the PETITFS library on writing, we do not implement - * writing. - * @note PETITFS can only have one file open at a time. - */ - #ifndef GFILE_NEED_PETITFS - #define GFILE_NEED_PETITFS FALSE - #endif - /** - * @brief Include the operating system's native file system - * @details Defaults to FALSE - * @note If GFILE_ALLOW_DEVICESPECIFIC is on then you can ensure that you are - * opening a file on the native file system by prefixing - * its name with "N|" (the letter 'N', followed by a vertical bar). - * @note If defined then the gfileStdOut and gfileStdErr handles - * use the operating system equivalent stdio and stderr. - * If it is not defined the gfileStdOut and gfileStdErr io is discarded. - */ - #ifndef GFILE_NEED_NATIVEFS - #define GFILE_NEED_NATIVEFS FALSE - #endif - /** - * @brief Include ChibiOS BaseFileStream support - * @details Defaults to FALSE - * @pre This is only relevant on the ChibiOS operating system. - * @note Use the @p gfileOpenBaseFileStream() call to open a GFILE based on a - * BaseFileStream. The BaseFileStream must already be open. - * @note A GFile of this type cannot be opened by filename. The BaseFileStream - * must be pre-opened using the operating system. - */ - #ifndef GFILE_NEED_CHIBIOSFS - #define GFILE_NEED_CHIBIOSFS FALSE - #endif - /** - * @brief Include raw memory pointer support - * @details Defaults to FALSE - * @note Use the @p gfileOpenMemory() call to open a GFILE based on a - * memory pointer. The GFILE opened appears to be of unlimited size. - * @note A GFile of this type cannot be opened by filename. - */ - #ifndef GFILE_NEED_MEMFS - #define GFILE_NEED_MEMFS FALSE - #endif - /** - * @brief Include support for file list functions - * @details Defaults to FALSE - * @note Adds support for @p gfileOpenFileList(), @p gfileReadFileList() and @p gfileCloseFileList(). - */ - #ifndef GFILE_NEED_FILELISTS - #define GFILE_NEED_FILELISTS FALSE - #endif -/** - * @} - * - * @name GFILE Optional Parameters - * @{ - */ - /** - * @brief Add floating point support to printg/scang etc. - */ - #ifndef GFILE_ALLOW_FLOATS - #define GFILE_ALLOW_FLOATS FALSE - #endif - /** - * @brief Can the device be specified as part of the file name. - * @note If this is on then a device letter and a vertical bar can be - * prefixed on a file name to specify that it must be on a - * specific device. - */ - #ifndef GFILE_ALLOW_DEVICESPECIFIC - #define GFILE_ALLOW_DEVICESPECIFIC FALSE - #endif - /** - * @brief The maximum number of open files - * @note This count excludes gfileStdIn, gfileStdOut and gfileStdErr - * (if open by default). - */ - #ifndef GFILE_MAX_GFILES - #define GFILE_MAX_GFILES 3 - #endif -/** @} */ - -#endif /* _GFILE_OPTIONS_H */ -/** @} */ diff --git a/src/gfile/sys_rules.h b/src/gfile/sys_rules.h deleted file mode 100644 index d13041f2..00000000 --- a/src/gfile/sys_rules.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - */ - -/** - * @file src/gfile/sys_rules.h - * @brief GFILE safety rules header file. - * - * @addtogroup GFILE - * @{ - */ - -#ifndef _GFILE_RULES_H -#define _GFILE_RULES_H - -#if GFX_USE_GFILE - #if GFILE_NEED_PETITFS && GFILE_NEED_FATFS - #error "GFILE: Both GFILE_NEED_PETITFS and GFILE_NEED_FATFS cannot both be turned on at the same time." - #endif -#endif - -#endif /* _GFILE_RULES_H */ -/** @} */ -- cgit v1.2.3