project_files/hwc/rtl/fileio.c
author antonc27 <antonc27@mail.ru>
Fri, 06 Nov 2015 04:34:29 +0100
branchios-revival
changeset 11314 8b40b2335e5b
parent 10575 13b1e9008f4b
child 11687 2c21bc80c95d
permissions -rw-r--r--
- Small corrections for rus localization of stats messages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     1
/*
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     2
 * XXX: assume all files are text files
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     3
 */
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     4
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     5
#include "misc.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     6
#include "fileio.h"
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     7
#include <string.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     8
#include <stdlib.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
     9
#include <assert.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    10
#include <sys/stat.h>
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    11
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    12
io_result_t IOResult;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    13
int FileMode;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    14
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    15
static void init(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    16
    f->fp = NULL;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    17
    f->eof = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    18
    f->mode = NULL;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    19
    f->record_len = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    20
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    21
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    22
void fpcrtl_assign__vars(File *f, string255 name) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    23
    FIX_STRING(name);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    24
    *f = (File) malloc(sizeof(file_wrapper_t));
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    25
    strcpy((*f)->file_name, name.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    26
    init(*f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    27
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    28
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    29
void fpcrtl_reset1(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    30
    f->fp = fopen(f->file_name, "r");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    31
    if (!f->fp) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    32
        IOResult = IO_ERROR_DUMMY;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    33
        printf("Failed to open %s\n", f->file_name);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    34
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    35
    } else {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    36
#ifdef FPCRTL_DEBUG
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    37
        printf("Opened %s\n", f->file_name);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    38
#endif
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    39
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    40
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    41
    f->mode = "r";
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    42
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    43
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    44
void fpcrtl_reset2(File f, int l) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    45
    f->eof = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    46
    f->fp = fopen(f->file_name, "rb");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    47
    if (!f->fp) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    48
        IOResult = IO_ERROR_DUMMY;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    49
        printf("Failed to open %s\n", f->file_name);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    50
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    51
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    52
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    53
    f->mode = "rb";
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    54
    f->record_len = l;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    55
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    56
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    57
void __attribute__((overloadable)) fpcrtl_rewrite(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    58
    f->fp = fopen(f->file_name, "w+");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    59
    if (!f->fp) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    60
        IOResult = IO_ERROR_DUMMY;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    61
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    62
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    63
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    64
    f->mode = "w+";
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    65
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    66
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    67
void __attribute__((overloadable)) fpcrtl_rewrite(File f, Integer l) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    68
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    69
    fpcrtl_rewrite(f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    70
    if (f->fp) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    71
        f->record_len = l;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    72
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    73
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    74
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    75
void fpcrtl_close(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    76
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    77
    fclose(f->fp);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    78
    free(f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    79
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    80
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    81
boolean fpcrtl_eof(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    82
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    83
    if (f->eof || f->fp == NULL || feof(f->fp)) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    84
        return true;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    85
    } else {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    86
        return false;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    87
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    88
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    89
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    90
void __attribute__((overloadable)) fpcrtl_readLn(File f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    91
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    92
    char line[256];
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    93
    if (fgets(line, sizeof(line), f->fp) == NULL) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    94
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    95
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    96
    if (feof(f->fp)) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    97
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    98
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
    99
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   100
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   101
void __attribute__((overloadable)) fpcrtl_readLn__vars(File f, Integer *i) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   102
    string255 s;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   103
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   104
    if (feof(f->fp)) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   105
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   106
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   107
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   108
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   109
    fpcrtl_readLn__vars(f, &s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   110
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   111
    *i = atoi(s.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   112
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   113
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   114
void __attribute__((overloadable)) fpcrtl_readLn__vars(File f, LongWord *i) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   115
    string255 s;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   116
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   117
    if (feof(f->fp)) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   118
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   119
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   120
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   121
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   122
    fpcrtl_readLn__vars(f, &s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   123
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   124
    *i = atoi(s.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   125
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   126
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   127
void __attribute__((overloadable)) fpcrtl_readLn__vars(File f, string255 *s) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   128
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   129
    if (fgets(s->str, 255, f->fp) == NULL) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   130
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   131
        s->len = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   132
        s->str[0] = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   133
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   134
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   135
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   136
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   137
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   138
    if (feof(f->fp)) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   139
        s->len = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   140
        f->eof = 1;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   141
        return;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   142
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   143
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   144
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   145
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   146
    s->len = strlen(s->str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   147
    if ((s->len > 0) && (s->str[s->len - 1] == '\n')) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   148
        s->str[s->len - 1] = 0;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   149
        s->len--;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   150
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   151
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   152
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   153
void __attribute__((overloadable)) fpcrtl_write(File f, string255 s) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   154
    FIX_STRING(s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   155
    fprintf(f->fp, "%s", s.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   156
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   157
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   158
void __attribute__((overloadable)) fpcrtl_write(FILE *f, string255 s) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   159
    FIX_STRING(s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   160
    fprintf(f, "%s", s.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   161
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   162
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   163
void __attribute__((overloadable)) fpcrtl_writeLn(File f, string255 s) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   164
    FIX_STRING(s);
10575
13b1e9008f4b super-filthy hack to allow pas2c to fallback to writing to stderr.
sheepluva
parents: 9966
diff changeset
   165
    // filthy hack to write to stderr
13b1e9008f4b super-filthy hack to allow pas2c to fallback to writing to stderr.
sheepluva
parents: 9966
diff changeset
   166
    if (!f->fp)
13b1e9008f4b super-filthy hack to allow pas2c to fallback to writing to stderr.
sheepluva
parents: 9966
diff changeset
   167
        fprintf(stderr, "%s\n", s.str);
13b1e9008f4b super-filthy hack to allow pas2c to fallback to writing to stderr.
sheepluva
parents: 9966
diff changeset
   168
    else
13b1e9008f4b super-filthy hack to allow pas2c to fallback to writing to stderr.
sheepluva
parents: 9966
diff changeset
   169
        fprintf(f->fp, "%s\n", s.str);
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   170
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   171
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   172
void __attribute__((overloadable)) fpcrtl_writeLn(FILE *f, string255 s) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   173
    FIX_STRING(s);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   174
    fprintf(f, "%s\n", s.str);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   175
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   176
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   177
void fpcrtl_blockRead__vars(File f, void *buf, Integer count, Integer *result) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   178
    assert(f->record_len > 0);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   179
    *result = fread(buf, f->record_len, count, f->fp);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   180
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   181
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   182
/*
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   183
 * XXX: dummy blockWrite
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   184
 */
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   185
void fpcrtl_blockWrite__vars(File f, const void *buf, Integer count,
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   186
        Integer *result) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   187
    assert(0);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   188
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   189
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   190
bool fpcrtl_directoryExists(string255 dir) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   191
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   192
    struct stat st;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   193
    FIX_STRING(dir);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   194
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   195
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   196
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   197
#ifdef FPCRTL_DEBUG
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   198
    printf("Warning: directoryExists is called. This may not work when compiled to js.\n");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   199
#endif
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   200
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   201
    if (stat(dir.str, &st) == 0) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   202
        return true;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   203
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   204
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   205
    return false;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   206
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   207
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   208
bool fpcrtl_fileExists(string255 filename) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   209
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   210
    FIX_STRING(filename);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   211
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   212
    IOResult = IO_NO_ERROR;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   213
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   214
    FILE *fp = fopen(filename.str, "r");
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   215
    if (fp) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   216
        fclose(fp);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   217
        return true;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   218
    }
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   219
    return false;
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   220
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   221
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   222
void __attribute__((overloadable)) fpcrtl_flush(Text f) {
9966
01e198990211 pas2c engine now writes debug log
unc0rr
parents: 7983
diff changeset
   223
    fflush(f->fp);
7983
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   224
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   225
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   226
void __attribute__((overloadable)) fpcrtl_flush(FILE *f) {
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   227
    fflush(f);
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   228
}
02f36c3e7f6c add xymeng's rtl port
koda
parents:
diff changeset
   229