/[projet1]/public/pc/tools/osdk/main/FloppyBuilder/FloppyBuilder.cpp
Defence Force logotype

Diff of /public/pc/tools/osdk/main/FloppyBuilder/FloppyBuilder.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1128 by Jylam, Tue May 6 21:15:53 2014 UTC revision 1129 by dbug, Sun May 11 09:17:25 2014 UTC
# Line 46  bool GetNextToken(std::string& returnedT Line 46  bool GetNextToken(std::string& returnedT
46        match =']';        match =']';
47      }      }
48    
49      while ( (car=*currentPosition) && ( (match && (car!=match)) || ( (!match) && ((car!=' ') && (car!='\t')) ) ) )      if (match)
50        {
51          // Push the starting character
52          returnedToken.push_back(car);
53          ++currentPosition;
54        }
55    
56        while ( (car=*currentPosition) && ( (match && (car!=match)) || ( (!match) && ((car!=' ') && (car!='\t')) ) ) )      
57      {      {
58        returnedToken.push_back(car);        returnedToken.push_back(car);
59        ++currentPosition;        ++currentPosition;
# Line 102  int main(int argc, char *argv[]) Line 109  int main(int argc, char *argv[])
109      "  Generating bootable floppies for the Oric computer.\r\n"      "  Generating bootable floppies for the Oric computer.\r\n"
110      "\r\n"      "\r\n"
111      "Usage:\r\n"      "Usage:\r\n"
112      "  {ApplicationName} <init|build> <description file path>\r\n"      "  {ApplicationName} <init|build|extract> <description file path>\r\n"
113      "\r\n"      "\r\n"
114      );      );
115    
# Line 129  int main(int argc, char *argv[]) Line 136  int main(int argc, char *argv[])
136    
137    Floppy floppy;    Floppy floppy;
138    
139      bool extract=false;
140    if (!strcmp(argv[param],"init"))    if (!strcmp(argv[param],"init"))
141    {    {
142      floppy.AllowMissingFiles(true);      floppy.AllowMissingFiles(true);
143    }    }
144    else    else
145      if (!strcmp(argv[param],"extract"))
146      {
147        floppy.AllowMissingFiles(true);
148        extract=true;
149      }
150      else
151    if (!strcmp(argv[param],"build"))    if (!strcmp(argv[param],"build"))
152    {    {
153      floppy.AllowMissingFiles(false);      floppy.AllowMissingFiles(false);
# Line 205  int main(int argc, char *argv[]) Line 219  int main(int argc, char *argv[])
219          else          else
220          {          {
221            // Let's say it's an actual parameter            // Let's say it's an actual parameter
222              item=StringTrim(item,"\"");
223            tokens.push_back(item);            tokens.push_back(item);
224          }          }
225        }        }
# Line 249  int main(int argc, char *argv[]) Line 264  int main(int argc, char *argv[])
264            }            }
265                    */                    */
266    
267                    if ( numberOfSectors!=17 )            if ( numberOfSectors!=17 )
268            {            {
269              ShowError("Syntax error line (%d), numberOfSectors has to be 17 (so far)\n",lineNumber);              ShowError("Syntax error line (%d), numberOfSectors has to be 17 (so far)\n",lineNumber);
270            }            }
# Line 361  int main(int argc, char *argv[]) Line 376  int main(int argc, char *argv[])
376          }          }
377        }        }
378        else        else
379          if (tokens[0]=="SaveFile")
380          {
381            // ; SaveFile "File_0.bin"  $80 $01 $47  ; Name Track Sector Lenght adress
382            if (tokens.size()==5)
383            {
384              std::string fileName=tokens[1];
385              int trackNumber =ConvertAdress(tokens[2].c_str());
386              int sectorNumber=ConvertAdress(tokens[3].c_str());
387              int sectorCount =ConvertAdress(tokens[4].c_str());
388              if (!floppy.ExtractFile(fileName.c_str(),trackNumber,sectorNumber,sectorCount))
389              {
390                ShowError("Error line (%d), could not extract file '%s' from disk. Make sure you have a valid floppy format declared and some available disk space. \n",lineNumber,fileName.c_str());
391              }
392            }
393            else
394            {
395              ShowError("Syntax error line (%d), syntax is 'ExtractFile FilePath TrackNumber SectorNumber SectorCount' \n",lineNumber);
396            }
397          }
398          else
399        if (tokens[0]=="AddDefine")        if (tokens[0]=="AddDefine")
400        {        {
401          if (tokens.size()==3)          if (tokens.size()==3)
# Line 404  int main(int argc, char *argv[]) Line 439  int main(int argc, char *argv[])
439    }    }
440    
441    
442      if (!extract)
   if (!floppy.SaveDescription(outputLayoutFileName.c_str()))  
443    {    {
444      ShowError("Failed saving description '%s'\n",outputLayoutFileName.c_str());      // We write the resulting files only in 'init' or 'build' mode
445    }      if (!floppy.SaveDescription(outputLayoutFileName.c_str()))
446        {
447          ShowError("Failed saving description '%s'\n",outputLayoutFileName.c_str());
448        }
449    
450    if (!floppy.SaveDisk(targetFloppyDiskName.c_str()))      if (!floppy.SaveDisk(targetFloppyDiskName.c_str()))
451    {      {
452      ShowError("Failed saving disk '%s'\n",targetFloppyDiskName.c_str());        ShowError("Failed saving disk '%s'\n",targetFloppyDiskName.c_str());
453    }      }
454    else      else
455    {      {
456      printf("Successfully created '%s'\n",targetFloppyDiskName.c_str());        printf("Successfully created '%s'\n",targetFloppyDiskName.c_str());
457        }
458    }    }
459  }  }

Legend:
Removed from v.1128  
changed lines
  Added in v.1129

  ViewVC Help
Powered by ViewVC 1.1.26