project_files/hwc/rtl/fileio.c
changeset 14934 68e1783762bc
parent 14444 a32b967f1341
equal deleted inserted replaced
14933:3a53309e684b 14934:68e1783762bc
   239 
   239 
   240 void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {
   240 void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {
   241     fflush(f);
   241     fflush(f);
   242 }
   242 }
   243 
   243 
       
   244 Int64 fpcrtl_fileSize(File f)
       
   245 {
       
   246     assert(f->record_len > 0);
       
   247 
       
   248     IOResult = IO_NO_ERROR;
       
   249     int i = fseek(f->fp, 0, SEEK_END);
       
   250     if (i == -1) {
       
   251         IOResult = IO_ERROR_DUMMY;
       
   252         return -1;
       
   253     }
       
   254     long size = ftell(f->fp);
       
   255     if (size == -1) {
       
   256         IOResult = IO_ERROR_DUMMY;
       
   257         return -1;
       
   258     }
       
   259     return size / f->record_len;
       
   260 }
       
   261 
       
   262 bool fpcrtl_deleteFile(string255 filename)
       
   263 {
       
   264     FIX_STRING(filename);
       
   265 
       
   266     int ret = remove(filename.str);
       
   267     if(ret == 0) {
       
   268        IOResult = IO_NO_ERROR;
       
   269        return true;
       
   270     } else {
       
   271        IOResult = IO_ERROR_DUMMY;
       
   272        return false;
       
   273     }
       
   274 }
       
   275