Пример #1
0
int ident_file(char *path, char *fn, int size)
{
   unsigned int crc;
   FILE *f;
   char fpath[256];

   //sprintf(fpath, "%s\\%s", path, fn);
   sprintf(fpath, "%s", fn);
   if (size == -1) {
      printf("fpath = %s\n", fpath);
      size = get_file_size(fpath);
      if (size < 1) {
         printf("Error, '%s' size incorrect (%s) !\n", fn, size);
         return 1;
      };
   };
   wbuf = (char *)malloc(size);
   if (!wbuf) {
      printf("Error, not enough memory to '%s' the file into memory !\n", fn);
      return 1;
   };
   f = fopen(fpath, "rb");
   if (!f) {
      printf("Error, cannot open file '%s' !\n", fpath);
      return 1;
   };
   fread(wbuf, 1, size, f);
   crc = crc32(0L, wbuf, size);
   fclose(f);
   free(wbuf);
   romident(fn, crc, size);
   return 0;
}
Пример #2
0
int ident_zip(char *fn)
{
   ZIP* zip;
   struct zipent* zipf;
   printf("Zip file to ident = '%s'\n", fn);
   if ((zip = openzip(fn)) == 0) {
      printf("Error, cannot open zip file '%s' !\n", fn);
      return 1;
   };
   while (zipf = readzip(zip)) {
      upper_case(zipf->name);
      romident(zipf->name, zipf->crc32, zipf->uncompressed_size);
   };
   closezip(zip);
   return 0;
}
Пример #3
0
static int info_romident(core_options *options, const char *gamename)
{
	romident_status status;

	/* a NULL gamename is a fatal error */
	if (gamename == NULL)
		return MAMERR_FATALERROR;

	/* do the identification */
	romident(gamename, &status);

	/* clear out any cached files */
	zip_file_cache_clear();

	/* return the appropriate error code */
	if (status.matches == status.total)
		return MAMERR_NONE;
	else if (status.matches == status.total - status.nonroms)
		return MAMERR_IDENT_NONROMS;
	else if (status.matches > 0)
		return MAMERR_IDENT_PARTIAL;
	else
		return MAMERR_IDENT_NONE;
}