bsnes/icarus/core/bsx-satellaview.cpp

41 lines
1.6 KiB
C++

auto Icarus::bsxSatellaviewManifest(const string& location) -> string {
vector<uint8_t> buffer;
concatenate(buffer, {location, "program.rom"});
return bsxSatellaviewManifest(buffer, location);
}
auto Icarus::bsxSatellaviewManifest(vector<uint8_t>& buffer, const string& location) -> string {
BsxSatellaviewCartridge 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::bsxSatellaviewImport(vector<uint8_t>& buffer, const string& location) -> bool {
auto name = location.prefixname();
auto source = location.pathname();
string target{settings.libraryPath, "BS-X Satellaview/", name, ".bs/"};
//if(directory::exists(target)) return failure("game already exists");
BsxSatellaviewCartridge 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();
}