Changeset 319 for AE/Installer/trunk
- Timestamp:
- May 5, 2009, 9:30:34 AM (16 years ago)
- Location:
- AE/Installer/trunk/source
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/Installer/trunk/source/methods.h
r314 r319 79 79 void tokenize(const string&, vector<string>&, const string& delimiters = " "); 80 80 //bool getDirectoryContents(char , char &); 81 81 void clearOldDats(void); 82 void writeInstalledMods( vector<string> ); 82 83 83 84 //New copy(path, path) function. Too lazy to implement my own, this is basically how I would have done it though. -
AE/Installer/trunk/source/subs.cpp
r318 r319 43 43 using namespace std; 44 44 45 string strInstallCfg = "../GameDataFolder/Install.cfg"; 45 46 46 47 … … 306 307 int installPackages(void) 307 308 { 309 bool installed_something = 0; 308 310 int err = 0; 309 311 ModPackage package; … … 356 358 if (package_iter->hasOnis || (package_iter->hasDeltas /*(*package_iter).isUnpacked */ )) 357 359 { 360 installed_something = 1; 358 361 installedMods.push_back(package_iter->modStringName); 359 362 system(strPauseCmd); … … 364 367 if (index == 1) 365 368 { 366 cout << "Error: All packages are already installed\n"; 369 cout << "Warning: All packages are already installed\n"; 370 //would you like to recombine your data? 367 371 return 0; 368 372 } 369 373 if (installed_something == 0) 374 { 375 cout << "Warning: You didn't install anything!\n"; 376 //would you like to recombine your data? 377 return 0; 378 } 379 370 380 sort(installedMods.begin(), installedMods.end()); 371 381 //system(Onisplit.c_str()); … … 378 388 int uninstallPackages(void) 379 389 { 380 cout << "\nThis feature not yet implemented.\n\n"; 381 382 return 0; 390 int err = 0; 391 ModPackage package; 392 vector<string> installed_packages; 393 vector<ModPackage> packages; 394 vector<ModPackage>::iterator iter; 395 vector<string> installString; 396 397 iter = packages.begin(); 398 packages = getPackages(); 399 400 401 cout << "Detecting installed packages...\n"; 402 403 vector<string> installedMods = getInstallString(); 404 405 if (packages.empty()) 406 { 407 cout << "Error: You have no packages!\n"; 408 return 0; 409 } 410 411 int index = 0; 412 int uninstalled_something = 0; 413 char choice = '0'; 414 415 for (vector<ModPackage>::iterator package_iter = packages.begin(); package_iter != packages.end(); ++package_iter) 416 { 417 if (binary_search(installedMods.begin(), installedMods.end(), package_iter->modStringName)) 418 { //package_iter->isInstalled :< I forgot about this... 419 //cout << index << " "; 420 system(strClsCmd); 421 cout << (*package_iter).name << "\n"; 422 for (int character = 1; character <= (*package_iter).name.length() - 1; character++) cout << '-'; 423 cout << "\n" 424 << (*package_iter).readme << "\n\n" 425 << "Please enter a number choice\n" 426 << " 1. Uninstall\n" 427 << " 2. Don't Uninstall\n" 428 << ""; 429 430 choice = 0; 431 432 do 433 { 434 choice = cin.get(); 435 cin.ignore(1280, '\n'); 436 } while(choice == 0); 437 438 if (choice == '1') 439 { 440 cout << "\nUninstalling...\n\n"; 441 installedMods.erase( installedMods.begin() + (index) ); 442 system(strPauseCmd); 443 uninstalled_something = 1; 444 445 } 446 else { 447 index++; 448 } 449 } 450 } 451 if ( uninstalled_something == 0 ) 452 { 453 if (index == 0) //bad practice, I need to implement a second vector or something. Meh. 454 { 455 cout << "\nWarning: You have no installed packages!"; 456 } 457 else 458 { 459 cout << "\nWarning: You didn't uninstall anything!"; 460 } 461 //would you like to recombine your data? 462 return 0; 463 464 } 465 sort(installedMods.begin(), installedMods.end()); 466 //system(Onisplit.c_str()); 467 recompileAll(installedMods); 468 system(strPauseCmd); 469 470 return err; 383 471 } 384 472 … … 552 640 string importCommand = ""; 553 641 554 directory_iterator end_iter_gdf; 555 for ( directory_iterator dir_itr_gdf( "../GameDataFolder" ); 556 dir_itr_gdf != end_iter_gdf; 557 ++dir_itr_gdf ) 558 { 559 //cout << dir_itr_gdf->path().extension() << "\n"; 560 if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) { 561 remove( dir_itr_gdf->path() ); 562 } 563 564 } 642 clearOldDats(); 565 643 566 644 if(splitInstances == SPLIT){ … … 620 698 } 621 699 } 700 writeInstalledMods(installedMods); 701 } 702 703 void writeInstalledMods(vector<string> installedMods) 704 { 705 706 if ( exists( strInstallCfg ) ) 707 { 708 remove( strInstallCfg ); 709 } 710 711 ofstream file(strInstallCfg.c_str()); 712 713 vector<string>list = installedMods; 714 vector<string>::iterator begin_iter = list.begin(); 715 vector<string>::iterator end_iter = list.end(); 716 717 sort( list.begin(), list.end() ); 718 719 for( ; begin_iter != end_iter; ++begin_iter) { 720 file << *begin_iter << " "; 721 } 722 723 file.close(); 724 file.clear(); 725 622 726 } 623 727 … … 626 730 system(strPauseCmd); 627 731 vector<string> returnval; 628 string file_name = "../GameDataFolder/ImportList.cfg"; 732 629 733 string line; 630 734 fstream file; 631 735 632 if (exists( file_name))633 { 634 file.open( file_name.c_str());736 if (exists(strInstallCfg )) 737 { 738 file.open(strInstallCfg.c_str()); 635 739 getline(file, line); 636 740 tokenize(line, returnval); … … 662 766 } 663 767 } 768 769 void clearOldDats(void) { 770 directory_iterator end_iter_gdf; 771 for ( directory_iterator dir_itr_gdf( "../GameDataFolder" ); 772 dir_itr_gdf != end_iter_gdf; 773 ++dir_itr_gdf ) 774 { 775 //cout << dir_itr_gdf->path().extension() << "\n"; 776 if ( dir_itr_gdf->path().extension() == ".dat" || dir_itr_gdf->path().extension() == ".raw" || dir_itr_gdf->path().extension() == ".sep" ) { 777 remove( dir_itr_gdf->path() ); 778 } 779 780 } 781 782 }
Note:
See TracChangeset
for help on using the changeset viewer.