#include #include #include #include // pour contourner un bug de std::vector ... #include "getopt_pp.h" /* Command line handling */ using namespace std; #include "MyType.h" #include "GestDsk.h" #include "Outils.h" #include "Main.h" #include "endianPPC.h" #include "ViewFile.h" int main(int argc, char** argv) { bool IsDskLoc, IsDskSet, ModeListDsk, ModeImportFile, ModeRemoveFile, ModeDisaFile, ModeListBasic, ModeListDams,ModeListHex, ModeGetFile, ModeNewDsk, Force_Overwrite, Read_only, System_file; ModeListDsk = ModeImportFile = ModeRemoveFile = ModeDisaFile = ModeListBasic = ModeListDams = ModeListHex = ModeNewDsk = ModeGetFile = IsDskLoc = IsDskSet = Force_Overwrite = Read_only = System_file = false ; string DskFile, AmsdosFile; vector AmsdosFileList; int exeAdress=0,loadAdress=0,AmsdosType=1, UserNumber=0; DSK MyDsk; IsDsk = IsDskValid = false; IsDskSaved = true; // Récupération des arguments avec getopt_pp {using namespace GetOpt; GetOpt_pp opts(argc,argv); opts >> GlobalOption(DskFile); if (DskFile != "") IsDskSet = true; opts >> OptionPresent('l',"list",ModeListDsk) >> OptionPresent('i',"import",ModeImportFile) >> Option('i',"import",AmsdosFileList) >> OptionPresent('r',"remove",ModeRemoveFile) >> Option('r',"remove",AmsdosFileList) >> OptionPresent('n',"new",ModeNewDsk) >> OptionPresent('z',"disassemble",ModeDisaFile) >> Option('z',"disassemble",AmsdosFileList) >> OptionPresent('b',"basic",ModeListBasic) >> Option('b',"basic",AmsdosFileList) >> OptionPresent('d',"dams",ModeListDams) >> Option('d',"dams",AmsdosFileList) >> OptionPresent('h',"hex",ModeListHex) >> Option('h',"hex",AmsdosFileList) >> std::hex >> Option('e',"exec",exeAdress) >> Option('c',"load",loadAdress) >> std::dec >> Option('t',"type",AmsdosType) >> OptionPresent('g',"get",ModeGetFile) >> Option('g',"get",AmsdosFileList) >> OptionPresent('f',"force",Force_Overwrite) >> OptionPresent('o',"write-protect",Read_only) >> OptionPresent('s',"system",System_file) >> Option('u',"user",UserNumber) ; if(opts.options_remain()) { cout << "Unhandled option ! Check the syntax." << endl; exit(EXIT_FAILURE); } }//namespace getopt if ( ! IsDskSet ) { cerr << "You did not select a DSK file to work with !" << endl; help(); } else cerr << "DSK : " << DskFile << endl; if ( ModeListBasic || ModeListHex || ModeListDams || ModeDisaFile ) { if ( ! MyDsk.ReadDsk(DskFile)) { cerr<< "Error reading file ("<< DskFile << ")."<::iterator iter=AmsdosFileList.begin(); iter!=AmsdosFileList.end(); iter++) { char* amsdosF = GetNomAmsdos(iter->c_str()); cerr << "Amsdos file : " << amsdosF << endl; if ( (Indice= MyDsk.FileIsIn( amsdosF ))<0) { cerr << "Error: File "<< amsdosF << " not found."<< endl; exit(EXIT_FAILURE); } MyDsk.OnViewFic(Indice); if ( ModeListBasic ) cout << ViewBasic( ) << endl; else if ( ModeListDams ) cout << "Not yet coded ! Please try a newer version of iDSK ! Sorry !"<::iterator iter=AmsdosFileList.begin(); iter!=AmsdosFileList.end(); iter++) { string amsdosfile = GetNomAmsdos(iter->c_str()); int Indice; if ( ( Indice = MyDsk.FileIsIn( amsdosfile ) ) != -1 && !Force_Overwrite) { cerr << "(" << amsdosfile <<") File exists, replace ? (Y/N) (try -f switch for autoreplace...):"; string answer ; cin >> answer; if ( toupper(answer[0]) == 'Y') MyDsk.RemoveFile(Indice); else { cerr<<"Import cancelled, dsk unchanged."<::iterator iter=AmsdosFileList.begin(); iter!=AmsdosFileList.end(); iter++) { char* amsdosF = GetNomAmsdos(iter->c_str()); cerr << "Amsdos file : " << amsdosF << endl; if ( (Indice= MyDsk.FileIsIn( amsdosF ))<0) { cerr << "Error : file "<< amsdosF << " not found."<< endl; exit(EXIT_FAILURE); } MyDsk.RemoveFile(Indice); if ( MyDsk.WriteDsk ((char*)DskFile.c_str()) ) cout << MyDsk.ReadDskDir(); else cerr<< "Error writing file " << (*iter) << endl; } } if ( ModeGetFile ) { if ( ! MyDsk.ReadDsk( (char*)DskFile.c_str() ) ) { cerr<< "Error reading dskfile ("<< DskFile << ")."<::iterator iter=AmsdosFileList.begin(); iter!=AmsdosFileList.end(); iter++) { char* amsdosF = GetNomAmsdos(iter->c_str()); cerr << "Fichier Amsdos : " << amsdosF << endl; if ( (Indice= MyDsk.FileIsIn( amsdosF ))<0) { cerr << "Error : file "<< amsdosF << " not found."<< endl; exit(EXIT_FAILURE); } if ( ! MyDsk.GetFileInDsk((char*)(*iter).c_str(),Indice) ) { cerr <<"System error : unable to copy ("< [OPTIONS] [files to process]" << endl; cout << "OPTIONS : EXAMPLE" << endl; cout << "-l : List disk catalog iDSK floppy.dsk -l" << endl; cout << "-g : export ('Get') file iDSK floppy.dsk -g myprog.bas"<