home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Sound / AmpPlaylistConv / AampPlaylistConvert-r.cpp < prev    next >
C/C++ Source or Header  |  2000-08-09  |  2KB  |  80 lines

  1. #include <fstream.h>
  2.  
  3. int errors=0;
  4.  
  5. int main(int argc, char **argv)
  6. {
  7.     short idx=0, idx2=0;
  8.     char buffer[500], path[200], artist[31], title[31], seconds[6];
  9.     fstream ein, aus;
  10.     cout <<"|  AampPlaylistConvert-r 1.0  |"<<endl;
  11.     cout <<"| by radiat-r@Sascha-Ploss.de |"<<endl;
  12.     if (argc == 3)
  13.     {
  14.         ein.open(argv[1],ios::in);
  15.         if (ein.is_open())
  16.         {
  17.             aus.open(argv[2],ios::out);
  18.             if (aus.is_open())
  19.             {
  20.                 ein.getline(buffer,500);
  21.                 while (!ein.eof())
  22.                 {
  23.                     idx=0;
  24.                     while (buffer[idx] != '\t')
  25.                     {
  26.                         path[idx]=buffer[idx];
  27.                         idx++;
  28.                     }
  29.                     path[idx]='\0';
  30.                     idx++;
  31.                     idx2=0;
  32.                     while (!((buffer[idx] == ' ') && (buffer[idx+1] == '-') && (buffer[idx+2] == ' ')))
  33.                     {
  34.                         artist[idx2]=buffer[idx];
  35.                         idx++;
  36.                         idx2++;
  37.                     }
  38.                     artist[idx2]='\0';
  39.                     idx+=3;
  40.                     idx2=0;
  41.                     while (buffer[idx] != '\t')
  42.                     {
  43.                         title[idx2]=buffer[idx];
  44.                         idx++;
  45.                         idx2++;
  46.                     }
  47.                     title[idx2]='\0';
  48.                     idx++;
  49.                     idx2=0;
  50.                     while (buffer[idx] != ' ')
  51.                     {
  52.                         seconds[idx2]=buffer[idx];
  53.                         idx++;
  54.                         idx2++;
  55.                     }
  56.                     seconds[idx2]='\0';
  57.                     aus <<path<<"\t"<<artist<<"\t"<<title<<"\t"<<seconds<<" seconds"<<endl;
  58.                     ein.getline(buffer,200);
  59.                 }
  60.             }
  61.             else // aus.is_open
  62.             {
  63.                 cout <<"Error while opening outputfile: "<<argv[2]<<endl;
  64.                 errors++;
  65.             }
  66.         }
  67.         else // ein.is_open
  68.         {
  69.             cout <<"Error while opening inputfile: "<<argv[1]<<endl;
  70.             errors++;
  71.         }
  72.     }
  73.     else // argc >< 3
  74.     {
  75.         cout <<"Error, wrong number of arguments,\nUsage: "<<argv[0]<<" Inputfile Outputfile"<<endl;
  76.         errors++;
  77.     }
  78.     return errors;
  79. }
  80.