aboutsummaryrefslogtreecommitdiffstats
path: root/src/gfile
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2018-11-03 10:51:23 +1000
committerinmarket <andrewh@inmarket.com.au>2018-11-03 10:51:23 +1000
commit7c5a6c928fa7129cf754c9c73c5c7ae39372ba9d (patch)
tree95cf152ef65ff19c7b2515b427bbe86b92b611d0 /src/gfile
parent8bd70d953bcd3e32ceb4e45a4e561c973726280a (diff)
downloaduGFX-7c5a6c928fa7129cf754c9c73c5c7ae39372ba9d.tar.gz
uGFX-7c5a6c928fa7129cf754c9c73c5c7ae39372ba9d.tar.bz2
uGFX-7c5a6c928fa7129cf754c9c73c5c7ae39372ba9d.zip
For all source files update integer types to the new gI8 etc type names
Diffstat (limited to 'src/gfile')
-rw-r--r--src/gfile/gfile.c20
-rw-r--r--src/gfile/gfile.h18
-rw-r--r--src/gfile/gfile_fatfs_diskio_chibios.c2
-rw-r--r--src/gfile/gfile_fatfs_wrapper.c2
-rw-r--r--src/gfile/gfile_fs.h12
-rw-r--r--src/gfile/gfile_fs_chibios.c8
-rw-r--r--src/gfile/gfile_fs_fatfs.c16
-rw-r--r--src/gfile/gfile_fs_mem.c4
-rw-r--r--src/gfile/gfile_fs_native.c24
-rw-r--r--src/gfile/gfile_fs_petitfs.c4
-rw-r--r--src/gfile/gfile_fs_rom.c20
-rw-r--r--src/gfile/gfile_stdio.c4
12 files changed, 67 insertions, 67 deletions
diff --git a/src/gfile/gfile.c b/src/gfile/gfile.c
index d01c416d..720ab815 100644
--- a/src/gfile/gfile.c
+++ b/src/gfile/gfile.c
@@ -175,9 +175,9 @@ gBool gfileDelete(const char *fname) {
return gFalse;
}
-long int gfileGetFilesize(const char *fname) {
+gFileSize gfileGetFilesize(const char *fname) {
const GFILEVMT * const *p;
- long int res;
+ gFileSize res;
#if GFILE_ALLOW_DEVICESPECIFIC
if (fname[0] && fname[1] == '|') {
@@ -185,7 +185,7 @@ long int gfileGetFilesize(const char *fname) {
if (p[0]->prefix == fname[0])
return p[0]->filesize ? p[0]->filesize(fname+2) : -1;
}
- return -1;
+ return (gFileSize)-1;
}
#endif
@@ -286,8 +286,8 @@ void gfileClose(GFILE *f) {
f->flags = 0;
}
-size_t gfileRead(GFILE *f, void *buf, size_t len) {
- size_t res;
+gMemSize gfileRead(GFILE *f, void *buf, gMemSize len) {
+ gMemSize res;
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_READ)) != (GFILEFLG_OPEN|GFILEFLG_READ))
return 0;
@@ -299,8 +299,8 @@ size_t gfileRead(GFILE *f, void *buf, size_t len) {
return res;
}
-size_t gfileWrite(GFILE *f, const void *buf, size_t len) {
- size_t res;
+gMemSize gfileWrite(GFILE *f, const void *buf, gMemSize len) {
+ gMemSize res;
if (!f || (f->flags & (GFILEFLG_OPEN|GFILEFLG_WRITE)) != (GFILEFLG_OPEN|GFILEFLG_WRITE))
return 0;
@@ -312,13 +312,13 @@ size_t gfileWrite(GFILE *f, const void *buf, size_t len) {
return res;
}
-long int gfileGetPos(GFILE *f) {
+gFileSize gfileGetPos(GFILE *f) {
if (!f || !(f->flags & GFILEFLG_OPEN))
return 0;
return f->pos;
}
-gBool gfileSetPos(GFILE *f, long int pos) {
+gBool gfileSetPos(GFILE *f, gFileSize pos) {
if (!f || !(f->flags & GFILEFLG_OPEN))
return gFalse;
if (!f->vmt->setpos || !f->vmt->setpos(f, pos))
@@ -327,7 +327,7 @@ gBool gfileSetPos(GFILE *f, long int pos) {
return gTrue;
}
-long int gfileGetSize(GFILE *f) {
+gFileSize gfileGetSize(GFILE *f) {
if (!f || !(f->flags & GFILEFLG_OPEN))
return 0;
if (!f->vmt->getsize)
diff --git a/src/gfile/gfile.h b/src/gfile/gfile.h
index 4ad3b302..5940a55b 100644
--- a/src/gfile/gfile.h
+++ b/src/gfile/gfile.h
@@ -70,11 +70,11 @@ gBool gfileDelete(const char *fname);
*
* @param[in] fname The file name
*
- * @return File size on success, -1 on error
+ * @return File size on success, (gFileSize)-1 on error
*
* @api
*/
-long int gfileGetFilesize(const char *fname);
+gFileSize gfileGetFilesize(const char *fname);
/**
* @brief Rename file
@@ -145,7 +145,7 @@ void gfileClose(GFILE *f);
*
* @api
*/
-size_t gfileRead(GFILE *f, void *buf, size_t len);
+gMemSize gfileRead(GFILE *f, void *buf, gMemSize len);
/**
* @brief Write to file
@@ -160,7 +160,7 @@ size_t gfileRead(GFILE *f, void *buf, size_t len);
*
* @api
*/
-size_t gfileWrite(GFILE *f, const void *buf, size_t len);
+gMemSize gfileWrite(GFILE *f, const void *buf, gMemSize len);
/**
* @brief Get the current position of the read/write cursor
@@ -171,7 +171,7 @@ size_t gfileWrite(GFILE *f, const void *buf, size_t len);
*
* @api
*/
-long int gfileGetPos(GFILE *f);
+gFileSize gfileGetPos(GFILE *f);
/**
* @brief Set the position of the read/write cursor
@@ -183,7 +183,7 @@ long int gfileGetPos(GFILE *f);
*
* @api
*/
-gBool gfileSetPos(GFILE *f, long int pos);
+gBool gfileSetPos(GFILE *f, gFileSize pos);
/**
* @brief Get the size of file
@@ -195,7 +195,7 @@ gBool gfileSetPos(GFILE *f, long int pos);
*
* @api
*/
-long int gfileGetSize(GFILE *f);
+gFileSize gfileGetSize(GFILE *f);
/**
* @brief Check for EOF
@@ -399,7 +399,7 @@ gBool gfileSync(GFILE *f);
// Needed routines and definitions
size_t gstdioRead(void * ptr, size_t size, size_t count, GFILE *f);
size_t gstdioWrite(const void * ptr, size_t size, size_t count, GFILE *f);
- int gstdioGetpos(GFILE *f, long int *pos);
+ int gstdioGetpos(GFILE *f, long *pos);
int gstdioSeek(GFILE *f, size_t offset, int origin);
#define SEEK_SET 0
#define SEEK_CUR 1
@@ -424,7 +424,7 @@ gBool gfileSync(GFILE *f);
#define rename(o,n) (!gfileRename(o,n))
#define fflush(f) (0)
#define ftell(f) gfileGetPos(f)
- #define fpos_t long int
+ #define fpos_t gFileSize
#define fgetpos(f,pos) gstdioGetpos(f,pos)
#define fsetpos(f, pos) (!gfileSetPos(f, *pos))
#define rewind(f) gfileSetPos(f, 0);
diff --git a/src/gfile/gfile_fatfs_diskio_chibios.c b/src/gfile/gfile_fatfs_diskio_chibios.c
index 13c7403d..9b13ff5b 100644
--- a/src/gfile/gfile_fatfs_diskio_chibios.c
+++ b/src/gfile/gfile_fatfs_diskio_chibios.c
@@ -271,7 +271,7 @@ DRESULT disk_ioctl (
}
#else
DWORD get_fattime(void) {
- return ((uint32_t)0 | (1 << 16)) | (1 << 21); /* wrong but valid time */
+ return ((gU32)0 | (1 << 16)) | (1 << 21); /* wrong but valid time */
}
#endif
diff --git a/src/gfile/gfile_fatfs_wrapper.c b/src/gfile/gfile_fatfs_wrapper.c
index 3099f508..4d846be6 100644
--- a/src/gfile/gfile_fatfs_wrapper.c
+++ b/src/gfile/gfile_fatfs_wrapper.c
@@ -68,7 +68,7 @@
/*------------------------------------------------------------------------*/
void *ff_memalloc(UINT size)
{
- return gfxAlloc( (size_t)size );
+ return gfxAlloc( (gMemSize)size );
}
/*------------------------------------------------------------------------*/
diff --git a/src/gfile/gfile_fs.h b/src/gfile/gfile_fs.h
index a19c5fba..4675352d 100644
--- a/src/gfile/gfile_fs.h
+++ b/src/gfile/gfile_fs.h
@@ -16,7 +16,7 @@
struct GFILE {
const struct GFILEVMT * vmt;
- uint16_t flags;
+ gU16 flags;
#define GFILEFLG_OPEN 0x0001 // File is open
#define GFILEFLG_READ 0x0002 // Read the file
#define GFILEFLG_WRITE 0x0004 // Write the file
@@ -29,7 +29,7 @@ struct GFILE {
#define GFILEFLG_MUSTNOTEXIST 0x0200 // On open file must not exist
#define GFILEFLG_TRUNC 0x0400 // On open truncate the file
void * obj;
- long int pos;
+ gFileSize pos;
};
struct gfileList {
@@ -38,7 +38,7 @@ struct gfileList {
};
typedef struct GFILEVMT {
- uint8_t flags;
+ gU8 flags;
#define GFSFLG_WRITEABLE 0x0001
#define GFSFLG_CASESENSITIVE 0x0002
#define GFSFLG_SEEKABLE 0x0004
@@ -48,14 +48,14 @@ typedef struct GFILEVMT {
char prefix;
gBool (*del) (const char *fname);
gBool (*exists) (const char *fname);
- long int (*filesize) (const char *fname);
+ gFileSize (*filesize) (const char *fname);
gBool (*ren) (const char *oldname, const char *newname);
gBool (*open) (GFILE *f, const char *fname);
void (*close) (GFILE *f);
int (*read) (GFILE *f, void *buf, int size);
int (*write) (GFILE *f, const void *buf, int size);
- gBool (*setpos) (GFILE *f, long int pos);
- long int (*getsize) (GFILE *f);
+ gBool (*setpos) (GFILE *f, gFileSize pos);
+ gFileSize (*getsize) (GFILE *f);
gBool (*eof) (GFILE *f);
gBool (*mount) (const char *drive);
gBool (*unmount) (const char *drive);
diff --git a/src/gfile/gfile_fs_chibios.c b/src/gfile/gfile_fs_chibios.c
index 65d259e9..d239bdd5 100644
--- a/src/gfile/gfile_fs_chibios.c
+++ b/src/gfile/gfile_fs_chibios.c
@@ -18,8 +18,8 @@
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 gBool ChibiOSBFSSetpos(GFILE *f, long int pos);
-static long int ChibiOSBFSGetsize(GFILE *f);
+static gBool ChibiOSBFSSetpos(GFILE *f, gFileSize pos);
+static gFileSize ChibiOSBFSGetsize(GFILE *f);
static gBool ChibiOSBFSEof(GFILE *f);
static const GFILEVMT FsCHIBIOSVMT = {
@@ -52,11 +52,11 @@ static int ChibiOSBFSRead(GFILE *f, void *buf, int size) {
static int ChibiOSBFSWrite(GFILE *f, const void *buf, int size) {
return fileStreamWrite(((FileStream *)f->obj), (uint8_t *)buf, size);
}
-static gBool ChibiOSBFSSetpos(GFILE *f, long int pos) {
+static gBool ChibiOSBFSSetpos(GFILE *f, gFileSize pos) {
fileStreamSeek(((FileStream *)f->obj), pos);
return gTrue;
}
-static long int ChibiOSBFSGetsize(GFILE *f) { return fileStreamGetSize(((FileStream *)f->obj)); }
+static gFileSize ChibiOSBFSGetsize(GFILE *f) { return (gFileSize)fileStreamGetSize(((FileStream *)f->obj)); }
static gBool ChibiOSBFSEof(GFILE *f) { return f->pos >= fileStreamGetSize(((FileStream *)f->obj)); }
GFILE * gfileOpenChibiOSFileStream(void *FileStreamPtr, const char *mode) {
diff --git a/src/gfile/gfile_fs_fatfs.c b/src/gfile/gfile_fs_fatfs.c
index d787ba09..4aae8c9f 100644
--- a/src/gfile/gfile_fs_fatfs.c
+++ b/src/gfile/gfile_fs_fatfs.c
@@ -22,14 +22,14 @@
static gBool fatfsDel(const char* fname);
static gBool fatfsExists(const char* fname);
-static long int fatfsFileSize(const char* fname);
+static gFileSize fatfsFileSize(const char* fname);
static gBool fatfsRename(const char* oldname, const char* newname);
static gBool fatfsOpen(GFILE* f, const char* fname);
static void fatfsClose(GFILE* f);
static int fatfsRead(GFILE* f, void* buf, int size);
static int fatfsWrite(GFILE* f, const void* buf, int size);
-static gBool fatfsSetPos(GFILE* f, long int pos);
-static long int fatfsGetSize(GFILE* f);
+static gBool fatfsSetPos(GFILE* f, gFileSize pos);
+static gFileSize fatfsGetSize(GFILE* f);
static gBool fatfsEOF(GFILE* f);
static gBool fatfsMount(const char* drive);
static gBool fatfsUnmount(const char* drive);
@@ -118,7 +118,7 @@ static gBool fatfsExists(const char* fname)
return gTrue;
}
-static long int fatfsFileSize(const char* fname)
+static gFileSize fatfsFileSize(const char* fname)
{
FRESULT ferr;
FILINFO fno;
@@ -127,7 +127,7 @@ static long int fatfsFileSize(const char* fname)
if (ferr != FR_OK)
return 0;
- return (long int)fno.fsize;
+ return (gFileSize)fno.fsize;
}
static gBool fatfsRename(const char* oldname, const char* newname)
@@ -201,7 +201,7 @@ static int fatfsWrite(GFILE* f, const void* buf, int size)
return wr;
}
-static gBool fatfsSetPos(GFILE* f, long int pos)
+static gBool fatfsSetPos(GFILE* f, gFileSize pos)
{
FRESULT ferr;
@@ -212,9 +212,9 @@ static gBool fatfsSetPos(GFILE* f, long int pos)
return gTrue;
}
-static long int fatfsGetSize(GFILE* f)
+static gFileSize fatfsGetSize(GFILE* f)
{
- return (long int)f_size( (FIL*)f->obj );
+ return (gFileSize)f_size( (FIL*)f->obj );
}
static gBool fatfsEOF(GFILE* f)
diff --git a/src/gfile/gfile_fs_mem.c b/src/gfile/gfile_fs_mem.c
index d87b8622..7aa0ce82 100644
--- a/src/gfile/gfile_fs_mem.c
+++ b/src/gfile/gfile_fs_mem.c
@@ -19,7 +19,7 @@
static int MEMRead(GFILE *f, void *buf, int size);
static int MEMWrite(GFILE *f, const void *buf, int size);
-static gBool MEMSetpos(GFILE *f, long int pos);
+static gBool MEMSetpos(GFILE *f, gFileSize pos);
static const GFILEVMT FsMemVMT = {
GFSFLG_SEEKABLE|GFSFLG_WRITEABLE, // flags
@@ -41,7 +41,7 @@ static int MEMWrite(GFILE *f, const void *buf, int size) {
memcpy(((char *)f->obj)+f->pos, buf, size);
return size;
}
-static gBool MEMSetpos(GFILE *f, long int pos) {
+static gBool MEMSetpos(GFILE *f, gFileSize pos) {
(void) f;
(void) pos;
return gTrue;
diff --git a/src/gfile/gfile_fs_native.c b/src/gfile/gfile_fs_native.c
index 8c12443b..39ebc960 100644
--- a/src/gfile/gfile_fs_native.c
+++ b/src/gfile/gfile_fs_native.c
@@ -24,14 +24,14 @@
static gBool NativeDel(const char *fname);
static gBool NativeExists(const char *fname);
-static long int NativeFilesize(const char *fname);
+static gFileSize NativeFilesize(const char *fname);
static gBool NativeRen(const char *oldname, const char *newname);
static gBool NativeOpen(GFILE *f, const char *fname);
static void NativeClose(GFILE *f);
static int NativeRead(GFILE *f, void *buf, int size);
static int NativeWrite(GFILE *f, const void *buf, int size);
-static gBool NativeSetpos(GFILE *f, long int pos);
-static long int NativeGetsize(GFILE *f);
+static gBool NativeSetpos(GFILE *f, gFileSize pos);
+static gFileSize NativeGetsize(GFILE *f);
static gBool NativeEof(GFILE *f);
#if GFILE_NEED_FILELISTS
static gfileList *NativeFlOpen(const char *path, gBool dirs);
@@ -78,7 +78,7 @@ void _gfileNativeAssignStdio(void) {
gfileStdErr = &NativeStdErr;
}
-static void Native_flags2mode(char *buf, uint16_t flags) {
+static void Native_flags2mode(char *buf, gU16 flags) {
if (flags & GFILEFLG_MUSTEXIST)
*buf = 'r';
else if (flags & GFILEFLG_APPEND)
@@ -99,19 +99,19 @@ static gBool NativeDel(const char *fname) { return remove(fname) ? gFalse
static void NativeClose(GFILE *f) { fclose((FILE *)f->obj); }
static int NativeRead(GFILE *f, void *buf, int size) { return fread(buf, 1, size, (FILE *)f->obj); }
static int NativeWrite(GFILE *f, const void *buf, int size) { return fwrite(buf, 1, size, (FILE *)f->obj); }
-static gBool NativeSetpos(GFILE *f, long int pos) { return fseek((FILE *)f->obj, pos, SEEK_SET) ? gFalse : gTrue; }
+static gBool NativeSetpos(GFILE *f, gFileSize pos) { return fseek((FILE *)f->obj, pos, SEEK_SET) ? gFalse : gTrue; }
static gBool NativeEof(GFILE *f) { return feof((FILE *)f->obj) ? gTrue : gFalse; }
static gBool NativeRen(const char *oldname, const char *newname) { return rename(oldname, newname) ? gFalse : gTrue; }
static gBool NativeExists(const char *fname) {
// We define access this way so we don't have to include <unistd.h> which may
- // (and does under windows) contain conflicting definitions for types such as uint16_t.
+ // (and does under windows) contain conflicting definitions for types such as gU16.
extern int access(const char *pathname, int mode);
return access(fname, 0) ? gFalse : gTrue;
}
-static long int NativeFilesize(const char *fname) {
+static gFileSize NativeFilesize(const char *fname) {
struct stat st;
- if (stat(fname, &st)) return -1;
- return st.st_size;
+ if (stat(fname, &st)) return (gFileSize)-1;
+ return (gFileSize)st.st_size;
}
static gBool NativeOpen(GFILE *f, const char *fname) {
FILE *fd;
@@ -123,10 +123,10 @@ static gBool NativeOpen(GFILE *f, const char *fname) {
f->obj = (void *)fd;
return gTrue;
}
-static long int NativeGetsize(GFILE *f) {
+static gFileSize NativeGetsize(GFILE *f) {
struct stat st;
- if (fstat(fileno((FILE *)f->obj), &st)) return -1;
- return st.st_size;
+ if (fstat(fileno((FILE *)f->obj), &st)) return (gFileSize)-1;
+ return (gFileSize)st.st_size;
}
#if GFILE_NEED_FILELISTS
diff --git a/src/gfile/gfile_fs_petitfs.c b/src/gfile/gfile_fs_petitfs.c
index a322a3b1..4fa51b31 100644
--- a/src/gfile/gfile_fs_petitfs.c
+++ b/src/gfile/gfile_fs_petitfs.c
@@ -19,7 +19,7 @@
static gBool petitfsExists(const char* fname);
static gBool petitfsOpen(GFILE* f, const char* fname);
static int petitfsRead(GFILE* f, void* buf, int size);
-static gBool petitfsSetPos(GFILE* f, long int pos);
+static gBool petitfsSetPos(GFILE* f, gFileSize pos);
#if GFILE_NEED_FILELISTS && _FS_MINIMIZE <= 1
static gfileList *petitfsFlOpen(const char *path, gBool dirs);
static const char *petitfsFlRead(gfileList *pfl);
@@ -103,7 +103,7 @@ static int petitfsRead(GFILE* f, void* buf, int size)
return br;
}
-static gBool petitfsSetPos(GFILE* f, long int pos)
+static gBool petitfsSetPos(GFILE* f, gFileSize pos)
{
(void) f;
return pf_lseek((DWORD)pos) == FR_OK;
diff --git a/src/gfile/gfile_fs_rom.c b/src/gfile/gfile_fs_rom.c
index 315f046e..56181086 100644
--- a/src/gfile/gfile_fs_rom.c
+++ b/src/gfile/gfile_fs_rom.c
@@ -24,11 +24,11 @@
#define ROMFS_CMP_UNCOMPRESSED 0
typedef struct ROMFS_DIRENTRY {
- uint16_t ver; // Directory Entry Version
- uint16_t cmp; // Compression format
+ gU16 ver; // Directory Entry Version
+ gU16 cmp; // Compression format
const struct ROMFS_DIRENTRY * next; // The next entry
const char * name; // The file name
- long int size; // The file size
+ gFileSize size; // The file size
const char * file; // The file data
} ROMFS_DIRENTRY;
@@ -43,12 +43,12 @@ typedef struct ROMFileList {
static gBool ROMExists(const char *fname);
-static long int ROMFilesize(const char *fname);
+static gFileSize ROMFilesize(const char *fname);
static gBool ROMOpen(GFILE *f, const char *fname);
static void ROMClose(GFILE *f);
static int ROMRead(GFILE *f, void *buf, int size);
-static gBool ROMSetpos(GFILE *f, long int pos);
-static long int ROMGetsize(GFILE *f);
+static gBool ROMSetpos(GFILE *f, gFileSize pos);
+static gFileSize ROMGetsize(GFILE *f);
static gBool ROMEof(GFILE *f);
#if GFILE_NEED_FILELISTS
static gfileList *ROMFlOpen(const char *path, gBool dirs);
@@ -84,11 +84,11 @@ static gBool ROMExists(const char *fname)
return ROMFindFile(fname) != 0;
}
-static long int ROMFilesize(const char *fname)
+static gFileSize ROMFilesize(const char *fname)
{
const ROMFS_DIRENTRY *p;
- if (!(p = ROMFindFile(fname))) return -1;
+ if (!(p = ROMFindFile(fname))) return (gFileSize)-1;
return p->size;
}
@@ -118,12 +118,12 @@ static int ROMRead(GFILE *f, void *buf, int size)
return size;
}
-static gBool ROMSetpos(GFILE *f, long int pos)
+static gBool ROMSetpos(GFILE *f, gFileSize pos)
{
return pos <= ((const ROMFS_DIRENTRY *)f->obj)->size;
}
-static long int ROMGetsize(GFILE *f)
+static gFileSize ROMGetsize(GFILE *f)
{
return ((const ROMFS_DIRENTRY *)f->obj)->size;
}
diff --git a/src/gfile/gfile_stdio.c b/src/gfile/gfile_stdio.c
index 1a045458..9cfc6b75 100644
--- a/src/gfile/gfile_stdio.c
+++ b/src/gfile/gfile_stdio.c
@@ -39,9 +39,9 @@ int gstdioSeek(GFILE *f, size_t offset, int origin) {
return gfileSetPos(f, offset) ? 0 : -1;
}
-int gstdioGetpos(GFILE *f, long int *pos) {
+int gstdioGetpos(GFILE *f, gFileSize *pos) {
if (!(f->flags & GFILEFLG_OPEN))
- return -1;
+ return (gFileSize)-1;
*pos = f->pos;
return 0;
}