/**************************************************************************************
$Id: file.c,v 1.2 2002/04/27 16:17:15 reddawg Exp $


**************************************************************************************/

#include <ubixfs/file.h>
#include <ubixfs/ubixfs.h>
#include <ubixos/video.h>

struct fileStruct fileTable[maxFiles];


int fopen(const char *filename,int flags,int mode) {
  int i = 0;
  for (i=0;i<maxFiles;i++) {
    if (fileTable[i].fileStatus != 1) break;
    }
  fileTable[i].fileMode  = mode;
  fileTable[i].fileFlags = flags;
  fileTable[i].fileName  = (void *)filename;
  fileTable[i].offset    = 0;
  fileTable[i].fileStatus    = 1;
  return(i);
  }

int fgetc(int fd) {
  int buf[1],result;
  if (fileTable[fd].fileStatus == 1) {
    result = getdata(fileTable[fd].fileName,fileTable[fd].offset,(unsigned long)1,(unsigned char *)buf);
    fileTable[fd].offset++;
    }
  else {
    buf[0] = 0x0;
    }
  return(buf[0]);
  }