Previous 199869 Revisions Next

r19336 Wednesday 5th December, 2012 at 15:29:19 UTC by Miodrag Milanović
Added ISO support to chdman and as mountable image device [Miodrag Milanovic]
[src/lib/util]chdcd.c

trunk/src/lib/util/chdcd.c
r19335r19336
449449}
450450
451451/*-------------------------------------------------
452    chdcd_parse_iso - parse a .ISO file
453-------------------------------------------------*/
454
455chd_error chdcd_parse_iso(const char *tocfname, cdrom_toc &outtoc, chdcd_track_input_info &outinfo)
456{
457   FILE *infile;
458   astring path = astring(tocfname);
459
460   infile = fopen(tocfname, "rt");
461   path = get_file_path(path);
462
463   if (infile == (FILE *)NULL)
464   {
465      return CHDERR_FILE_NOT_FOUND;
466   }
467
468   /* clear structures */
469   memset(&outtoc, 0, sizeof(outtoc));
470   outinfo.reset();
471
472   fseek(infile, 0, SEEK_END);   
473   long size = ftell(infile);
474   fclose(infile);
475
476
477   outtoc.numtrks = 1;
478
479   outinfo.track[0].fname = tocfname;
480   outinfo.track[0].offset = 0;
481   outinfo.track[0].idx0offs = 0;
482   outinfo.track[0].idx1offs = 0;
483
484   if ((size % 2048)==0 ) {
485      outtoc.tracks[0].trktype = CD_TRACK_MODE1;
486      outtoc.tracks[0].frames = size / 2048;
487      outtoc.tracks[0].datasize = 2048;
488      outinfo.track[0].swap = false;
489   } else {
490      // 2352 byte mode 2 raw
491      outtoc.tracks[0].trktype = CD_TRACK_MODE2_RAW;
492      outtoc.tracks[0].frames = size / 2352;
493      outtoc.tracks[0].datasize = 2352;
494      outinfo.track[0].swap = false;
495   }   
496
497   outtoc.tracks[0].subtype = CD_SUB_NONE;
498   outtoc.tracks[0].subsize = 0;
499
500   outtoc.tracks[0].pregap = 0;
501   
502   outtoc.tracks[0].postgap = 0;
503   outtoc.tracks[0].pgtype = 0;
504   outtoc.tracks[0].pgsub = CD_SUB_NONE;
505   outtoc.tracks[0].pgdatasize = 0;
506   outtoc.tracks[0].pgsubsize = 0;
507   outtoc.tracks[0].padframes = 0;
508
509
510   return CHDERR_NONE;
511}
512
513/*-------------------------------------------------
452514    chdcd_parse_gdi - parse a Sega GD-ROM rip
453515-------------------------------------------------*/
454516
r19335r19336
861923      return chdcd_parse_nero(tocfname, outtoc, outinfo);
862924   }
863925
926   if (strstr(tocftemp,".iso"))
927   {
928      return chdcd_parse_iso(tocfname, outtoc, outinfo);
929   }
930
864931   astring path = astring(tocfname);
865932
866933   infile = fopen(tocfname, "rt");

Previous 199869 Revisions Next


© 1997-2024 The MAME Team