decoder.c
branchtrunk
changeset 34 afc13760179b
parent 33 65ed49cbc08b
equal deleted inserted replaced
33:65ed49cbc08b 34:afc13760179b
   135 
   135 
   136 void cSongInfo::FakeTitle(const char *filename, const char *extention)
   136 void cSongInfo::FakeTitle(const char *filename, const char *extention)
   137 {
   137 {
   138   // if no title, try to build a reasonable from the filename
   138   // if no title, try to build a reasonable from the filename
   139   if(!Title && filename)  {
   139   if(!Title && filename)  {
   140     char *s=rindex(filename,'/');
   140     const char *s=rindex(filename,'/');
   141     if(s && *s=='/') {
   141     if(s && *s=='/') {
   142       s++;
   142       s++;
   143       Title=strdup(s);
   143       Title=strdup(s);
   144       strreplace(Title,'_',' ');
   144       strreplace(Title,'_',' ');
   145       if(extention) {                            // strip given extention
   145       if(extention) {                            // strip given extention
   146         int l=strlen(Title)-strlen(extention);
   146         int l=strlen(Title)-strlen(extention);
   147         if(l>0 && !strcasecmp(Title+l,extention)) Title[l]=0;
   147         if(l>0 && !strcasecmp(Title+l,extention)) Title[l]=0;
   148         }
   148         }
   149       else {                                     // strip any extention
   149       else {                                     // strip any extention
   150         s=rindex(Title,'.');
   150         char *e=rindex(Title,'.');
   151         if(s && *s=='.' && strlen(s)<=5) *s=0;
   151         if(e && *e=='.' && strlen(e)<=5) *e=0;
   152         }
   152         }
   153       d(printf("mp3: faking title '%s' from filename '%s'\n",Title,filename))
   153       d(printf("mp3: faking title '%s' from filename '%s'\n",Title,filename))
   154       }
   154       }
   155     }
   155     }
   156 }
   156 }