13
13
#define HostOS 0x01
14
14
// #endif
15
15
16
+ #if !defined(FILE_TYPE )
17
+ #define FILE_TYPE FsFile
18
+ #endif
19
+
16
20
#if defined CORE_TEENSY
17
21
#define HostOS 0x04
18
22
#endif
26
30
/* Memory abstraction functions */
27
31
/*===============================================================================*/
28
32
bool _RamLoad (char * filename , uint16 address ) {
29
- File32 f ;
33
+ FILE_TYPE f ;
30
34
bool result = false;
31
35
32
36
if (f = SD .open (filename , FILE_READ )) {
@@ -40,7 +44,7 @@ bool _RamLoad(char* filename, uint16 address) {
40
44
41
45
/* Filesystem (disk) abstraction fuctions */
42
46
/*===============================================================================*/
43
- File32 rootdir , userdir ;
47
+ FILE_TYPE rootdir , userdir ;
44
48
#define FOLDERCHAR '/'
45
49
46
50
typedef struct {
@@ -60,31 +64,29 @@ typedef struct {
60
64
uint8 al [16 ];
61
65
} CPM_DIRENTRY ;
62
66
63
- static DirFat_t fileDirEntry ;
64
-
65
67
bool _sys_exists (uint8 * filename ) {
66
68
return (SD .exists ((const char * )filename ));
67
69
}
68
70
69
- File32 _sys_fopen_w (uint8 * filename ) {
71
+ FILE_TYPE _sys_fopen_w (uint8 * filename ) {
70
72
return (SD .open ((char * )filename , O_CREAT | O_WRITE ));
71
73
}
72
74
73
- int _sys_fputc (uint8 ch , File32 & f ) {
75
+ int _sys_fputc (uint8 ch , FILE_TYPE & f ) {
74
76
return (f .write (ch ));
75
77
}
76
78
77
- void _sys_fflush (File32 & f ) {
79
+ void _sys_fflush (FILE_TYPE & f ) {
78
80
f .flush ();
79
81
}
80
82
81
- void _sys_fclose (File32 & f ) {
83
+ void _sys_fclose (FILE_TYPE & f ) {
82
84
f .close ();
83
85
}
84
86
85
87
int _sys_select (uint8 * disk ) {
86
88
uint8 result = FALSE;
87
- File32 f ;
89
+ FILE_TYPE f ;
88
90
89
91
digitalWrite (LED , HIGH ^ LEDinv );
90
92
if (f = SD .open ((char * )disk , O_READ )) {
@@ -98,7 +100,7 @@ int _sys_select(uint8* disk) {
98
100
99
101
long _sys_filesize (uint8 * filename ) {
100
102
long l = -1 ;
101
- File32 f ;
103
+ FILE_TYPE f ;
102
104
103
105
digitalWrite (LED , HIGH ^ LEDinv );
104
106
if (f = SD .open ((char * )filename , O_RDONLY )) {
@@ -110,13 +112,12 @@ long _sys_filesize(uint8* filename) {
110
112
}
111
113
112
114
int _sys_openfile (uint8 * filename ) {
113
- File32 f ;
115
+ FILE_TYPE f ;
114
116
int result = 0 ;
115
117
116
118
digitalWrite (LED , HIGH ^ LEDinv );
117
119
f = SD .open ((char * )filename , O_READ );
118
120
if (f ) {
119
- f .dirEntry (& fileDirEntry );
120
121
f .close ();
121
122
result = 1 ;
122
123
}
@@ -125,7 +126,7 @@ int _sys_openfile(uint8* filename) {
125
126
}
126
127
127
128
int _sys_makefile (uint8 * filename ) {
128
- File32 f ;
129
+ FILE_TYPE f ;
129
130
int result = 0 ;
130
131
131
132
digitalWrite (LED , HIGH ^ LEDinv );
@@ -145,7 +146,7 @@ int _sys_deletefile(uint8* filename) {
145
146
}
146
147
147
148
int _sys_renamefile (uint8 * filename , uint8 * newname ) {
148
- File32 f ;
149
+ FILE_TYPE f ;
149
150
int result = 0 ;
150
151
151
152
digitalWrite (LED , HIGH ^ LEDinv );
@@ -165,7 +166,7 @@ void _sys_logbuffer(uint8* buffer) {
165
166
#ifdef CONSOLELOG
166
167
puts ((char * )buffer );
167
168
#else
168
- File32 f ;
169
+ FILE_TYPE f ;
169
170
uint8 s = 0 ;
170
171
while (* (buffer + s )) // Computes buffer size
171
172
++ s ;
@@ -181,7 +182,7 @@ void _sys_logbuffer(uint8* buffer) {
181
182
bool _sys_extendfile (char * fn , unsigned long fpos )
182
183
{
183
184
uint8 result = true;
184
- File32 f ;
185
+ FILE_TYPE f ;
185
186
unsigned long i ;
186
187
187
188
digitalWrite (LED , HIGH ^ LEDinv );
@@ -204,7 +205,7 @@ bool _sys_extendfile(char* fn, unsigned long fpos)
204
205
205
206
uint8 _sys_readseq (uint8 * filename , long fpos ) {
206
207
uint8 result = 0xff ;
207
- File32 f ;
208
+ FILE_TYPE f ;
208
209
uint8 bytesread ;
209
210
uint8 dmabuf [BlkSZ ];
210
211
uint8 i ;
@@ -234,7 +235,7 @@ uint8 _sys_readseq(uint8* filename, long fpos) {
234
235
235
236
uint8 _sys_writeseq (uint8 * filename , long fpos ) {
236
237
uint8 result = 0xff ;
237
- File32 f ;
238
+ FILE_TYPE f ;
238
239
239
240
digitalWrite (LED , HIGH ^ LEDinv );
240
241
if (_sys_extendfile ((char * )filename , fpos ))
@@ -256,7 +257,7 @@ uint8 _sys_writeseq(uint8* filename, long fpos) {
256
257
257
258
uint8 _sys_readrand (uint8 * filename , long fpos ) {
258
259
uint8 result = 0xff ;
259
- File32 f ;
260
+ FILE_TYPE f ;
260
261
uint8 bytesread ;
261
262
uint8 dmabuf [BlkSZ ];
262
263
uint8 i ;
@@ -297,7 +298,7 @@ uint8 _sys_readrand(uint8* filename, long fpos) {
297
298
298
299
uint8 _sys_writerand (uint8 * filename , long fpos ) {
299
300
uint8 result = 0xff ;
300
- File32 f ;
301
+ FILE_TYPE f ;
301
302
302
303
digitalWrite (LED , HIGH ^ LEDinv );
303
304
if (_sys_extendfile ((char * )filename , fpos )) {
@@ -325,7 +326,7 @@ static uint16 fileExtentsUsed = 0;
325
326
static uint16 firstFreeAllocBlock ;
326
327
327
328
uint8 _findnext (uint8 isdir ) {
328
- File32 f ;
329
+ FILE_TYPE f ;
329
330
uint8 result = 0xff ;
330
331
bool isfile ;
331
332
uint32 bytes ;
@@ -339,7 +340,6 @@ uint8 _findnext(uint8 isdir) {
339
340
f .getName ((char * )& findNextDirName [0 ], 13 );
340
341
isfile = !f .isDirectory ();
341
342
bytes = f .size ();
342
- f .dirEntry (& fileDirEntry );
343
343
f .close ();
344
344
if (!isfile )
345
345
continue ;
@@ -440,7 +440,7 @@ uint8 _findfirstallusers(uint8 isdir) {
440
440
}
441
441
442
442
uint8 _Truncate (char * filename , uint8 rc ) {
443
- File32 f ;
443
+ FILE_TYPE f ;
444
444
int result = 0 ;
445
445
446
446
digitalWrite (LED , HIGH ^ LEDinv );
0 commit comments