mirror of https://github.com/bsnes-emu/bsnes.git
41 lines
1.5 KiB
C++
41 lines
1.5 KiB
C++
auto Icarus::sufamiTurboManifest(const string& location) -> string {
|
|
vector<uint8_t> buffer;
|
|
concatenate(buffer, {location, "program.rom"});
|
|
return sufamiTurboManifest(buffer, location);
|
|
}
|
|
|
|
auto Icarus::sufamiTurboManifest(vector<uint8_t>& buffer, const string& location) -> string {
|
|
SufamiTurboCartridge cartridge{buffer.data(), buffer.size()};
|
|
if(auto markup = cartridge.markup) {
|
|
markup.append("\n");
|
|
markup.append("information\n");
|
|
markup.append(" sha256: ", Hash::SHA256(buffer.data(), buffer.size()).digest(), "\n");
|
|
markup.append(" title: ", location.prefixname(), "\n");
|
|
markup.append(" note: ", "heuristically generated by icarus\n");
|
|
return markup;
|
|
}
|
|
return "";
|
|
}
|
|
|
|
auto Icarus::sufamiTurboImport(vector<uint8_t>& buffer, const string& location) -> bool {
|
|
auto name = location.prefixname();
|
|
auto source = location.pathname();
|
|
string target{settings.libraryPath, "Sufami Turbo/", name, ".st/"};
|
|
//if(directory::exists(target)) return failure("game already exists");
|
|
|
|
SufamiTurboCartridge cartridge{buffer.data(), buffer.size()};
|
|
auto markup = cartridge.markup;
|
|
if(!markup) return failure("does not appear to be a valid image");
|
|
|
|
markup.append("\n");
|
|
markup.append("information\n");
|
|
markup.append(" title: ", name, "\n");
|
|
markup.append(" note: heuristically generated by icarus\n");
|
|
|
|
if(!directory::create(target)) return failure("library path unwritable");
|
|
|
|
if(settings.createManifests) file::write({target, "manifest.bml"}, markup);
|
|
file::write({target, "program.rom"}, buffer);
|
|
return success();
|
|
}
|