Beispiel #1
0
PostLoadCommand MAMELoader::Apply(RawFile *file) {
  if (!bLoadedXml)
    return KEEP_IT;
  if (file->GetExtension() != L"zip")
    return KEEP_IT;

  wstring fullfilename_w = file->GetFileName();
  string fullfilename = wstring2string(fullfilename_w);
  const char *endoffilename = strrchr(fullfilename.c_str(), '.');
  char filename[10] = {0};
  strncpy(filename, fullfilename.c_str(), endoffilename - fullfilename.c_str());

  // look up the game name in our little database
  GameMap::iterator it = gamemap.find(filename);
  if (it == gamemap.end())        //if we couldn't find an entry for the game name
    return KEEP_IT;               //don't do anything

  MAMEGameEntry *gameentry = it->second;

  //Get the format given and check if it is defined in VGMTrans
  Format *fmt = Format::GetFormatFromName(gameentry->format);
  if (!fmt)
    return KEEP_IT;

  //try to open up the game zip
  wstring fullpath = file->GetFullPath();
  string test = wstring2string(fullpath);
  unzFile cur_file = unzOpen(wstring2string(fullpath).c_str());
  if (!cur_file) {
    return KEEP_IT;
  }
  int ret;

  //Now we try to load the rom groups.  We save the created file into the rom MAMERomGroupEntry's file member
  // Note that this does not check for an error, so the romgroup entry's file member may receive NULL.
  // This must be checked for in Scan().
  for (list<MAMERomGroupEntry>::iterator it = gameentry->romgroupentries.begin();
       it != gameentry->romgroupentries.end(); it++)
    it->file = LoadRomGroup(&(*it), gameentry->format, cur_file);


  fmt->GetScanner().Scan(NULL, gameentry);

  for (list<MAMERomGroupEntry>::iterator it = gameentry->romgroupentries.begin();
       it != gameentry->romgroupentries.end(); it++) {
    if (it->file != NULL)
      pRoot->SetupNewRawFile(it->file);
  }

  ret = unzClose(cur_file);
  if (ret != UNZ_OK) {
    return KEEP_IT;
  }

  return DELETE_IT;
}
Beispiel #2
0
void VGMRoot::AddScanner(const string& formatname)
{
	Format* fmt = Format::GetFormatFromName(formatname);
	if (!fmt)
		return;
	VGMScanner& scanner = fmt->GetScanner();
	if (!scanner.Init())
		return;
	vScanner.push_back(&scanner);
}