aboutsummaryrefslogtreecommitdiff
path: root/backends/gp32/gp32std.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/gp32/gp32std.cpp')
-rw-r--r--backends/gp32/gp32std.cpp194
1 files changed, 0 insertions, 194 deletions
diff --git a/backends/gp32/gp32std.cpp b/backends/gp32/gp32std.cpp
index 2a7f06177d..2e3cbea6cc 100644
--- a/backends/gp32/gp32std.cpp
+++ b/backends/gp32/gp32std.cpp
@@ -34,12 +34,6 @@
#include "backends/gp32/gp32std.h"
#include "backends/gp32/gp32std_grap.h"
-FILE *gp_stderr = NULL;
-FILE *gp_stdout = NULL;
-FILE *gp_stdin = NULL;
-
-//#define USE_CACHE
-
#define DEBUG_MAX 5
char debline[DEBUG_MAX][256];
static int debnext = 0;
@@ -71,194 +65,6 @@ void _dprintf(const char *s, ...) {
// gp_delay(100);
}
-//////////////////
-//File functions
-
-GPFILE *gp_fopen(const char *fileName, const char *openMode) {
- //FIXME: allocation, mode, malloc -> new
- uint32 mode;
- GPFILE *file;
- ERR_CODE err;
- char tempPath[256];
-
- if (!strchr(fileName, '.')) {
- sprintf(tempPath, "%s.", fileName);
- fileName = tempPath;
- }
-
- file = (GPFILE *)malloc(sizeof(GPFILE));
-
-// NP("%s(\"%s\", \"%s\")", __FUNCTION__, fileName, openMode);
-
- // FIXME add binary/text support
- if (tolower(openMode[0]) == 'r') {
- mode = OPEN_R;
- GpFileGetSize(fileName, &file->size);
- err = GpFileOpen(fileName, mode, &file->handle);
- } else if (tolower(openMode[0]) == 'w') {
- //printf("open if as W");
- file->size = 0; // FIXME? new file has no size?
- file->cachePos = 0;
- mode = OPEN_W;
- err = GpFileCreate(fileName, ALWAYS_CREATE, &file->handle);
- } else if (tolower(openMode[0]) == 'a') {
- warning("We do not support 'a' file open mode.");
- free(file);
- return NULL;
- } else {
- error("wrong file mode");
- }
-
- if (!file) {
- error("%s: cannot create FILE structure", __FUNCTION__);
- }
- if (err) {
-// BP("%s: IO error %d", __FUNCTION__, err);
- free(file);
- return NULL;
- }
-
- return file;
-}
-
-int gp_fclose(GPFILE *stream) {
- if (!stream) {
- //warning("closing null file");
- return 1;
- }
-
-/* if (*(uint32 *)((char *)stream - sizeof(uint32)) == 0x4321) {
- debug(0, "Double closing", __FUNCTION__);
- return 1;
- }
-*/
-
-#ifdef USE_CACHE
- if (stream->cachePos) {
- GpFileWrite(stream->handle, (char *)stream->cacheData, stream->cachePos); // flush cache
- stream->cachePos = 0;
- }
-#endif
-
- ERR_CODE err = GpFileClose(stream->handle);
- free(stream);
-
- return err;
-}
-
-int gp_fseek(GPFILE *stream, long offset, int whence) {
- ulong dummy;
-
- switch (whence) {
- case SEEK_SET:
- whence = FROM_BEGIN;
- break;
- case SEEK_CUR:
- whence = FROM_CURRENT;
- break;
- case SEEK_END:
- whence = FROM_END;
- break;
- }
- return GpFileSeek(stream->handle, whence, offset, (long *)&dummy);
-}
-
-//TODO: read cache
-size_t gp_fread(void *ptr, size_t size, size_t n, GPFILE *stream) {
- ulong readcount = 0;
- ERR_CODE err = GpFileRead(stream->handle, ptr, size * n, &readcount); //fixme? size*n
- return readcount / size; //FIXME?
-}
-
-size_t gp_fwrite(const void *ptr, size_t size, size_t n, GPFILE *stream) {
- int len = size * n;
-
- if (!stream) {
- //warning("writing to null file");
- return 0;
- }
-
-#ifdef USE_CACHE
- if (stream->cachePos + len < FCACHE_SIZE) {
- memcpy(stream->cacheData + stream->cachePos, ptr, len);
- stream->cachePos += len;
- } else {
- if (stream->cachePos) {
- GpFileWrite(stream->handle, stream->cacheData, stream->cachePos); // flush cache
- stream->cachePos = 0;
- }
-
-#endif
- ERR_CODE err = GpFileWrite(stream->handle, ptr, len);
- if (!err)
- return n;
- else
- return -err;
-#ifdef USE_CACHE
- }
-#endif
- return 0;
-}
-
-//FIXME? use standard func
-long gp_ftell(GPFILE *stream) {
- ulong pos = 0;
- ERR_CODE err = GpFileSeek(stream->handle, FROM_CURRENT, 0, (long*)&pos);
- return pos;
-}
-
-void gp_clearerr(GPFILE *stream)
-{
-}
-
-//FIXME!
-int gp_feof(GPFILE *stream) {
- return gp_ftell(stream) >= stream->size;
-}
-
-char gp_fgetc(GPFILE *stream) {
- char c[1];
-
- gp_fread(&c[0], 1, 1, stream);
- return c[0];
-}
-
-char *gp_fgets(char *s, int n, GPFILE *stream) {
- int i = 0;
-
- while (!gp_feof(stream) && i < n) {
- gp_fread(&s[i], 1, 1, stream);
- if (s[i] == '\n') {
- s[i + 1] = 0;
- return s;
- }
- i++;
- }
- if (gp_feof(stream))
- return NULL;
- else
- return s;
-}
-
-int gp_fprintf(GPFILE *stream, const char *fmt, ...) {
- char s[256];
- va_list marker;
-
- va_start(marker, fmt);
- vsnprintf(s, 256, fmt, marker);
- va_end(marker);
-
- return gp_fwrite(s, 1, strlen(s), stream);
-}
-
-int gp_fflush(GPFILE *stream) {
- return 0;
-}
-
-int gp_ferror(GPFILE *stream) {
- return 0;
-}
-
/////////////////////
//Memory management
#undef memcpy