Added filename decoding to strings
This commit is contained in:
parent
ec314d7b1b
commit
2c4c76d1e7
20
kernel32.c
20
kernel32.c
@ -56,8 +56,28 @@ int main() {
|
|||||||
set_curpos(0, 0);
|
set_curpos(0, 0);
|
||||||
} else if (strcmp(buffer, "echo", 4)) {
|
} else if (strcmp(buffer, "echo", 4)) {
|
||||||
printf("%s\n", rest);
|
printf("%s\n", rest);
|
||||||
|
} else if (strcmp(buffer, "type", 4)) {
|
||||||
|
char filenamebuffer[12];
|
||||||
|
uint8_t* filebuffer = 0x1006400;
|
||||||
|
|
||||||
|
decode_filename(rest, filenamebuffer);
|
||||||
|
if (!file_exists(filenamebuffer)) {
|
||||||
|
printf("File %s not found!\n", filenamebuffer);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<1024; i++)
|
||||||
|
hellotxt[i] = 0;
|
||||||
|
|
||||||
|
load_file(filenamebuffer, filebuffer);
|
||||||
|
printf(filebuffer);
|
||||||
} else {
|
} else {
|
||||||
|
char filenamebuffer[12];
|
||||||
|
decode_filename(buffer, filenamebuffer);
|
||||||
|
if (!file_exists(filenamebuffer)) {
|
||||||
printf("Bad Command or filename!\n");
|
printf("Bad Command or filename!\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
22
strings.c
22
strings.c
@ -45,3 +45,25 @@ int string_split(char delimeter, char* string, char** pointer_array) {
|
|||||||
|
|
||||||
return split_count;
|
return split_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void decode_filename(char* nice_name, char* filenamebuffer) {
|
||||||
|
// Clear filenamebuffer
|
||||||
|
for (int i=0; i<11; i++)
|
||||||
|
filenamebuffer[i] = ' ';
|
||||||
|
filenamebuffer[11] = 0;
|
||||||
|
|
||||||
|
int fbIndex = 0;
|
||||||
|
for (int i=0; i<12; i++) {
|
||||||
|
if (nice_name[i] == 0)
|
||||||
|
return;
|
||||||
|
if (nice_name[i] == '.') {
|
||||||
|
fbIndex = 8;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nice_name[i] >= 0x65 && nice_name[i] <= 0x65+26)
|
||||||
|
filenamebuffer[fbIndex++] = nice_name[i] & (0xff - 32);
|
||||||
|
else
|
||||||
|
filenamebuffer[fbIndex++] = nice_name[i];
|
||||||
|
}
|
||||||
|
}
|
@ -6,5 +6,6 @@
|
|||||||
bool strcmp(char* a, char* b, int max);
|
bool strcmp(char* a, char* b, int max);
|
||||||
char* split_on_first(char delimeter, char* string);
|
char* split_on_first(char delimeter, char* string);
|
||||||
int string_split(char delimeter, char* string, char** pointer_array);
|
int string_split(char delimeter, char* string, char** pointer_array);
|
||||||
|
void decode_filename(char* nice_name, char* filenamebuffer);
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user