equal
deleted
inserted
replaced
81 FioSeekTo(FioGetPos(), SEEK_SET); |
81 FioSeekTo(FioGetPos(), SEEK_SET); |
82 _fio.pos += size; |
82 _fio.pos += size; |
83 fread(ptr, 1, size, _fio.cur_fh); |
83 fread(ptr, 1, size, _fio.cur_fh); |
84 } |
84 } |
85 |
85 |
|
86 static inline void FioCloseFile(int slot) |
|
87 { |
|
88 if (_fio.handles[slot] != NULL) { |
|
89 fclose(_fio.handles[slot]); |
|
90 _fio.handles[slot] = NULL; |
|
91 } |
|
92 } |
|
93 |
86 void FioCloseAll(void) |
94 void FioCloseAll(void) |
87 { |
95 { |
88 int i; |
96 int i; |
89 |
97 |
90 for (i = 0; i != lengthof(_fio.handles); i++) { |
98 for (i = 0; i != lengthof(_fio.handles); i++) |
91 if (_fio.handles[i] != NULL) { |
99 FioCloseFile(i); |
92 fclose(_fio.handles[i]); |
|
93 _fio.handles[i] = NULL; |
|
94 } |
|
95 } |
|
96 } |
100 } |
97 |
101 |
98 void FioOpenFile(int slot, const char *filename) |
102 void FioOpenFile(int slot, const char *filename) |
99 { |
103 { |
100 FILE *f; |
104 FILE *f; |
124 #endif |
128 #endif |
125 |
129 |
126 if (f == NULL) |
130 if (f == NULL) |
127 error("Cannot open file '%s'", buf); |
131 error("Cannot open file '%s'", buf); |
128 |
132 |
|
133 FioCloseFile(slot); // if file was opened before, close it |
129 _fio.handles[slot] = f; |
134 _fio.handles[slot] = f; |
130 FioSeekToFile(slot << 24); |
135 FioSeekToFile(slot << 24); |
131 } |
136 } |
132 |
137 |
133 |
138 |