| ... | ... |
@@ -22,7 +22,7 @@ WITH REGARD TO THIS SOFTWARE. |
| 22 | 22 |
typedef struct {
|
| 23 | 23 |
FILE *f; |
| 24 | 24 |
DIR *dir; |
| 25 |
- char *current_filename; |
|
| 25 |
+ char current_filename[4096]; |
|
| 26 | 26 |
struct dirent *de; |
| 27 | 27 |
enum { IDLE,
|
| 28 | 28 |
FILE_READ, |
| ... | ... |
@@ -66,7 +66,7 @@ get_entry(char *p, Uint16 len, const char *pathname, const char *basename, int f |
| 66 | 66 |
static Uint16 |
| 67 | 67 |
file_read_dir(UxnFile *c, char *dest, Uint16 len) |
| 68 | 68 |
{
|
| 69 |
- static char pathname[4096]; |
|
| 69 |
+ static char pathname[4352]; |
|
| 70 | 70 |
char *p = dest; |
| 71 | 71 |
if(c->de == NULL) c->de = readdir(c->dir); |
| 72 | 72 |
for(; c->de != NULL; c->de = readdir(c->dir)) {
|
| ... | ... |
@@ -86,10 +86,18 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len) |
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 | 88 |
static Uint16 |
| 89 |
-file_init(UxnFile *c, void *filename) |
|
| 89 |
+file_init(UxnFile *c, char *filename, size_t max_len) |
|
| 90 | 90 |
{
|
| 91 |
+ char *p = c->current_filename; |
|
| 92 |
+ size_t len = sizeof(c->current_filename); |
|
| 91 | 93 |
reset(c); |
| 92 |
- c->current_filename = filename; |
|
| 94 |
+ if(len > max_len) len = max_len; |
|
| 95 |
+ while(len) {
|
|
| 96 |
+ if((*p++ = *filename++) == '\0') |
|
| 97 |
+ return 0; |
|
| 98 |
+ len--; |
|
| 99 |
+ } |
|
| 100 |
+ c->current_filename[0] = '\0'; |
|
| 93 | 101 |
return 0; |
| 94 | 102 |
} |
| 95 | 103 |
|
| ... | ... |
@@ -165,7 +173,7 @@ file_i_deo(int instance, Device *d, Uint8 port) |
| 165 | 173 |
break; |
| 166 | 174 |
case 0x9: |
| 167 | 175 |
DEVPEEK16(addr, 0x8); |
| 168 |
- res = file_init(c, (char *)&d->u->ram[addr]); |
|
| 176 |
+ res = file_init(c, (char *)&d->u->ram[addr], 0x10000 - addr); |
|
| 169 | 177 |
DEVPOKE16(0x2, res); |
| 170 | 178 |
break; |
| 171 | 179 |
case 0xd: |