Previous 15994 Revisions Next

r14537 Sunday 19th February, 2012 at 18:16:58 UTC by Miodrag Milanović
Sync with MAME r15461 (no whatsnew)
[src/lib/util]cdrom.c chdcd.c chdcd.h

src/lib/util/cdrom.c
r14536r14537
141141      file_error filerr = core_fopen(file->track_info.track[i].fname, OPEN_FLAG_READ, &file->fhandle[i]);
142142      if (filerr != FILERR_NONE)
143143      {
144         fprintf(stderr, "Unable to open file: %s\n", file->track_info.track[i].fname);
144         fprintf(stderr, "Unable to open file: %s\n", file->track_info.track[i].fname.cstr());
145145         return NULL;
146146      }
147147   }
src/lib/util/chdcd.c
r14536r14537
140140    length in bytes of the data and the offset in
141141    bytes to where the data starts in the file.
142142-------------------------------------------------*/
143static UINT32 parse_wav_sample(char *filename, UINT32 *dataoffs)
143static UINT32 parse_wav_sample(const char *filename, UINT32 *dataoffs)
144144{
145145   unsigned long offset = 0;
146146   UINT32 length, rate, filesize;
r14536r14537
387387            index1 = read_uint64(infile);
388388            index2 = read_uint64(infile);
389389
390                //printf("Track %d: sector size %d mode %x index0 %llx index1 %llx index2 %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, index2, (UINT32)(index1-index0)/size, (UINT32)(index2-index1)/size);
391//            outinfo.track[track-1].fname.cpy(path.cstr()).cat(tocfname);
392                strncpy(outinfo.track[track-1].fname, path.cstr(), 256);
393                strncat(outinfo.track[track-1].fname, tocfname, 256);
390//              printf("Track %d: sector size %d mode %x index0 %llx index1 %llx index2 %llx (pregap %d sectors, length %d sectors)\n", track, size, mode, index0, index1, index2, (UINT32)(index1-index0)/size, (UINT32)(index2-index1)/size);
391            outinfo.track[track-1].fname.cpy(path).cat(tocfname);
394392            outinfo.track[track-1].offset = offset + (UINT32)(index1-index0);
395393            outinfo.track[track-1].idx0offs = 0;
396394            outinfo.track[track-1].idx1offs = 0;
r14536r14537
540538         } while(tok!=NULL && (strrchr(tok,'"')-tok !=(strlen(tok)-1)));
541539         name = name.delchr('"');
542540      }
543        strncpy(outinfo.track[trknum].fname, path.cstr(), 256);
544        strncat(outinfo.track[trknum].fname, name, 256);
541      outinfo.track[trknum].fname.cpy(path).cat(name);
545542
546543      sz=get_file_size(outinfo.track[trknum].fname);
547544
r14536r14537
590587   FILE *infile;
591588   int i, trknum;
592589   static char token[512];
593   static char lastfname[256];
590   astring lastfname;
594591   UINT32 wavlen, wavoffs;
595592   astring path = astring(tocfname);
596593
r14536r14537
626623            TOKENIZE
627624
628625            /* keep the filename */
629            strncpy(lastfname, path.cstr(), 256);
630            strncat(lastfname, token, 256);
626            lastfname.cpy(path).cat(token);
631627
632628            /* get the file type */
633629            TOKENIZE
r14536r14537
652648                  if (err != FILERR_NONE) printf("holy moley!\n");
653649                  else core_fclose(fhand);
654650
655                  printf("ERROR: couldn't read [%s] or not a valid .WAV\n", lastfname);
651                  printf("ERROR: couldn't read [%s] or not a valid .WAV\n", lastfname.cstr());
656652                  return CHDERR_FILE_NOT_FOUND;
657653               }
658654            }
r14536r14537
690686            outinfo.track[trknum].idx0offs = -1;
691687            outinfo.track[trknum].idx1offs = 0;
692688
693            strncpy(outinfo.track[trknum].fname, lastfname, 256); // default filename to the last one
689            outinfo.track[trknum].fname.cpy(lastfname); // default filename to the last one
694690
695691//              printf("trk %d: fname %s offset %d\n", trknum, outinfo.track[trknum].fname.cstr(), outinfo.track[trknum].offset);
696692
r14536r14537
778774         if (trknum == (outtoc.numtrks-1))
779775         {
780776            /* if we have the same filename as the last track, do it that way */
781            if (outinfo.track[trknum].fname == outinfo.track[trknum-1].fname)
777            if (trknum != 0 && outinfo.track[trknum].fname == outinfo.track[trknum-1].fname)
782778            {
783               tlen = get_file_size(outinfo.track[trknum].fname);
779               tlen = get_file_size(outinfo.track[trknum].fname.cstr());
784780               if (tlen == 0)
785781               {
786                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname);
782                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname.cstr());
787783                  return CHDERR_FILE_NOT_FOUND;
788784               }
789785               outinfo.track[trknum].offset = outinfo.track[trknum-1].offset + outtoc.tracks[trknum-1].frames * (outtoc.tracks[trknum-1].datasize + outtoc.tracks[trknum-1].subsize);
r14536r14537
794790               tlen = get_file_size(outinfo.track[trknum].fname);
795791               if (tlen == 0)
796792               {
797                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname);
793                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum-1].fname.cstr());
798794                  return CHDERR_FILE_NOT_FOUND;
799795               }
800796               tlen /= (outtoc.tracks[trknum].datasize + outtoc.tracks[trknum].subsize);
r14536r14537
829825               tlen = get_file_size(outinfo.track[trknum].fname);
830826               if (tlen == 0)
831827               {
832                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum].fname);
828                  printf("ERROR: couldn't find bin file [%s]\n", outinfo.track[trknum].fname.cstr());
833829                  return CHDERR_FILE_NOT_FOUND;
834830               }
835831               tlen /= (outtoc.tracks[trknum].datasize + outtoc.tracks[trknum].subsize);
r14536r14537
912908            TOKENIZE
913909
914910            /* keep the filename */
915                strncpy(outinfo.track[trknum].fname, path.cstr(), 256);
916                strncat(outinfo.track[trknum].fname, token, 256);
911            outinfo.track[trknum].fname.cpy(path).cat(token);
917912
918913            /* get either the offset or the length */
919914            TOKENIZE
src/lib/util/chdcd.h
r14536r14537
1717struct chdcd_track_input_entry
1818{
1919   chdcd_track_input_entry() { reset(); }
20   void reset() { fname[0] = '\0'; offset = idx0offs = idx1offs = 0; swap = false; }
20   void reset() { fname.reset(); offset = idx0offs = idx1offs = 0; swap = false; }
2121
22   char fname[1024];      // filename for each track
22   astring fname;      // filename for each track
2323   UINT32 offset;      // offset in the data file for each track
2424   bool swap;         // data needs to be byte swapped
2525   UINT32 idx0offs;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team