project_files/hwc/rtl/fileio.c
changeset 11682 2c21bc80c95d
parent 10575 13b1e9008f4b
child 14423 a32b967f1341
equal deleted inserted replaced
11681:8fca9fd31357 11682:2c21bc80c95d
     6 #include "fileio.h"
     6 #include "fileio.h"
     7 #include <string.h>
     7 #include <string.h>
     8 #include <stdlib.h>
     8 #include <stdlib.h>
     9 #include <assert.h>
     9 #include <assert.h>
    10 #include <sys/stat.h>
    10 #include <sys/stat.h>
       
    11 #include <unistd.h>
    11 
    12 
    12 io_result_t IOResult;
    13 io_result_t IOResult;
    13 int FileMode;
    14 int FileMode;
       
    15 char cwd[1024];
    14 
    16 
    15 static void init(File f) {
    17 static void init(File f) {
    16     f->fp = NULL;
    18     f->fp = NULL;
    17     f->eof = 0;
    19     f->eof = 0;
    18     f->mode = NULL;
    20     f->mode = NULL;
   217         return true;
   219         return true;
   218     }
   220     }
   219     return false;
   221     return false;
   220 }
   222 }
   221 
   223 
       
   224 char * fpcrtl_getCurrentDir(void) {
       
   225 
       
   226     IOResult = IO_NO_ERROR;
       
   227 
       
   228     if (getcwd(cwd, sizeof(cwd)) != NULL)
       
   229         return cwd;
       
   230 
       
   231     IOResult = IO_ERROR_DUMMY;
       
   232     return "";
       
   233 }
       
   234 
   222 void __attribute__((overloadable)) fpcrtl_flush(Text f) {
   235 void __attribute__((overloadable)) fpcrtl_flush(Text f) {
   223     fflush(f->fp);
   236     fflush(f->fp);
   224 }
   237 }
   225 
   238 
   226 void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {
   239 void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {