Previous 15994 Revisions Next

r12669 Saturday 20th August, 2011 at 06:37:12 UTC by Miodrag Milanović
chdcd changes imported from MAME (no whatsnew)
[src/tools]chdcd.c

src/tools/chdcd.c
r12668r12669
3737    IMPLEMENTATION
3838***************************************************************************/
3939
40static astring get_file_path(astring &path)
41{   
42   int pos = path.rchr( 0, '\\');
43   if (pos!=-1) {
44      path = path.substr(0,pos+1);
45   } else {
46      pos = path.rchr( 0, '/');
47      path = path.substr(0,pos+1);
48   }
49   return path;
50}
4051/*-------------------------------------------------
4152    get_file_size - get the size of a file
4253-------------------------------------------------*/
r12668r12669
300311   UINT32 chain_offs, chunk_size;
301312   int done = 0;
302313
303   infile = fopen(tocfname, "rt");
314   astring path = astring(tocfname);
304315
316   infile = fopen(tocfname, "rt");   
317   path = get_file_path(path);
318
305319   if (infile == (FILE *)NULL)
306320   {
307321      return CHDERR_FILE_NOT_FOUND;
r12668r12669
374388            index2 = read_uint64(infile);
375389
376390//              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);
377
378            strcpy(outinfo->fname[track-1], tocfname);
391            strncpy(outinfo->fname[track-1], path.cstr(), 256);
392            strncat(outinfo->fname[track-1], tocfname, 256);
379393            outinfo->offset[track-1] = offset + (UINT32)(index1-index0);
380394            outinfo->idx0offs[track-1] = 0;
381395            outinfo->idx1offs[track-1] = 0;
r12668r12669
444458   int i, numtracks;
445459   //int chdpos=0;
446460
447   infile = fopen(tocfname, "rt");
461   astring path = astring(tocfname);
448462
463   infile = fopen(tocfname, "rt");   
464   path = get_file_path(path);
465
449466   if (infile == (FILE *)NULL)
450467   {
451468      return CHDERR_FILE_NOT_FOUND;
r12668r12669
508525         outtoc->tracks[trknum].datasize=2352;
509526      }
510527
511      tok=strtok(NULL," ");
512      strcpy(&(outinfo->fname[trknum][0]),tok);
528      astring name;
529     
530      tok=strtok(NULL," ");     
531      name = tok;
532      if (tok[0]=='"') {
533         do {
534            tok=strtok(NULL," ");           
535            if (tok!=NULL) {
536               name += " ";
537               name += tok;
538            }
539         } while(tok!=NULL && (strrchr(tok,'"')-tok !=(strlen(tok)-1)));
540         name = name.delchr('"');
541      }
542      strncpy(outinfo->fname[trknum], path.cstr(), 256);
543      strncat(outinfo->fname[trknum], name, 256);
544     
513545      sz=get_file_size(outinfo->fname[trknum]);
514546
515547      outtoc->tracks[trknum].frames=sz/trksize;
r12668r12669
557589   FILE *infile;
558590   int i, trknum;
559591   static char token[128];
560   static char lastfname[128];
592   static char lastfname[256];
561593   UINT32 wavlen, wavoffs;
594   astring path = astring(tocfname);
562595
563   infile = fopen(tocfname, "rt");
564
596   infile = fopen(tocfname, "rt");   
597   path = get_file_path(path);
565598   if (infile == (FILE *)NULL)
566599   {
567600      return CHDERR_FILE_NOT_FOUND;
r12668r12669
592625            TOKENIZE
593626
594627            /* keep the filename */
595            strncpy(lastfname, token, 128);
628            strncpy(lastfname, path.cstr(), 256);
629            strncat(lastfname, token, 256);
596630
597631            /* get the file type */
598632            TOKENIZE
r12668r12669
654688            outtoc->tracks[trknum].pregap = 0;
655689            outinfo->idx0offs[trknum] = -1;
656690            outinfo->idx1offs[trknum] = 0;
657            strcpy(&outinfo->fname[trknum][0], lastfname);   // default filename to the last one
691
692            strncpy(outinfo->fname[trknum], lastfname, 256); // default filename to the last one
658693//              printf("trk %d: fname %s offset %d\n", trknum, &outinfo->fname[trknum][0], outinfo->offset[trknum]);
659694
660695            cdrom_convert_type_string_to_track_info(token, &outtoc->tracks[trknum]);
r12668r12669
832867      return chdcd_parse_nero(tocfname, outtoc, outinfo);
833868   }
834869
835   infile = fopen(tocfname, "rt");
870   astring path = astring(tocfname);
836871
872   infile = fopen(tocfname, "rt");   
873   path = get_file_path(path);
874
837875   if (infile == (FILE *)NULL)
838876   {
839877      return CHDERR_FILE_NOT_FOUND;
r12668r12669
865903            TOKENIZE
866904
867905            /* keep the filename */
868            strncpy(&outinfo->fname[trknum][0], token, strlen(token));
906            strncpy(outinfo->fname[trknum], path.cstr(), 256);
907            strncat(outinfo->fname[trknum], token, 256);
869908
870909            /* get either the offset or the length */
871910            TOKENIZE

Previous 15994 Revisions Next


© 1998-2018 The MESS Team