implement GBA file not found command

This commit is contained in:
Martin Michelsen
2023-10-05 10:28:04 -07:00
parent 6850bc0e06
commit 682632f1c5
2 changed files with 20 additions and 15 deletions
+11 -6
View File
@@ -2436,13 +2436,18 @@ static void on_D7_GC(shared_ptr<Client> c, uint16_t, uint32_t, const string& dat
string filename(data);
strip_trailing_zeroes(filename);
if (filename.find('/') != string::npos) {
throw runtime_error("GBA file name includes directory separator");
send_command(c, 0xD7, 0x00);
} else {
try {
static FileContentsCache gba_file_cache(300 * 1000 * 1000);
auto f = gba_file_cache.get_or_load("system/gba/" + filename).file;
send_open_quest_file(c, "", filename, f->data, QuestFileType::GBA_DEMO);
} catch (const out_of_range&) {
send_command(c, 0xD7, 0x00);
} catch (const cannot_open_file&) {
send_command(c, 0xD7, 0x00);
}
}
static FileContentsCache gba_file_cache(300 * 1000 * 1000);
auto f = gba_file_cache.get_or_load("system/gba/" + filename).file;
send_open_quest_file(c, "", filename, f->data, QuestFileType::GBA_DEMO);
}
static void send_file_chunk(