Changeset 1498 for trunk/gsinstaller/gsinstall.cpp
- Timestamp:
- 2000-09-05T03:30:48+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsinstaller/gsinstall.cpp
r1475 r1498 67 67 bool installNetscape(); 68 68 void setDestination(); 69 voidsetUninstall();69 bool setUninstall(); 70 70 void uninstall(); 71 71 void setManifest(); … … 320 320 } 321 321 322 void GSInstall::setUninstall() 323 { 324 // open the log for reading 325 FilePath *logPath = new FilePath(this->collectPath->pathString(), "install.log"); 322 bool GSInstall::setUninstall() 323 { char tempPathStr[MAX_PATH]; 324 325 // if we failed to get the Windows temporary directory, abort 326 if (GetTempPath(MAX_PATH, tempPathStr) == 0) 327 { // TODO: abort! 328 return false; 329 } 330 331 FilePath tempPath(tempPathStr); 332 333 // if we are not running in the Windows temporary directory, copy this exe 334 // and the installation log to the temporary directory and run them there 335 if (*this->sourcePath != tempPath) 336 { // copy this and install.log to temporary directory and restart 337 FilePath exePath(*this->sourcePath, "gssetup.exe"); 338 FilePath logPath(*this->sourcePath, "install.log"); 339 340 FilePath exeDest(tempPath, "gssetup.exe"); 341 FilePath logDest(tempPath, "install.log"); 342 343 CopyFile(exePath.cString(), exeDest.cString(), false); 344 CopyFile(logPath.cString(), logDest.cString(), false); 345 346 // now run the gssetup in the temporary directory 347 launchApp launchUninstall(exeDest); 348 launchUninstall.setCommandLine(" -u " + logPath.pathString()); 349 launchUninstall.run(false, 0, "", "", false); 350 351 return false; 352 } 353 354 // open the log for reading from the directory this exe is now in (which 355 // will in fact be the temporary directory as outlined above) 356 FilePath *logPath = new FilePath(this->sourcePath->pathString(), "install.log"); 326 357 this->openLog(logPath->pathString(), false); 327 358 delete logPath; 359 360 return true; 328 361 } 329 362 … … 338 371 gsProfile gsdlProfile(*this, iniPath->pathString()); 339 372 340 while ((command = this-> readCommand(params)) != "")373 while ((command = this->popCommand(params)) != "") 341 374 { if (!this->manifest->undoAction(command, params)) 342 375 { if (!gsdlProfile.undoAction(command, params)) … … 752 785 case WM_USER: 753 786 { // uninstall action 754 if (strstr(app_cmdLine, "-u") != NULL || true) 755 { char *at = strstr(app_cmdLine, "-u"); 756 at += strlen("-u") + 1; 787 if (strstr(app_cmdLine, "-u") != NULL) 788 { // skip past the -u option itself 789 char *at = strstr(app_cmdLine, "-u"); 790 at += strlen("-u"); 791 792 // extract the log file path from the command line 793 while (*at == ' ') 794 { at ++; 795 } 796 string logPathString(at); 797 FilePath logPath(logPathString); 757 798 758 799 GSInstall install(true); 759 install.setUninstall(); 760 install.uninstall(); 800 // if we're running in the temporary directory, do the uninstall 801 if (install.setUninstall()) 802 { install.uninstall(); 803 804 // close the log to write back all changes to the log; if the file 805 // will be deleted, it must be closed; copying may also fail, so it's 806 // safer to close it before doing either. 807 install.closeLog(); 808 809 // if the install is empty, terminate all final items (currently the 810 // log and setup executables, 811 if (install.isEmpty()) 812 { // delete the log file 813 DeleteFile(logPath.cString()); 814 815 // get it's parent to find where the gssetup executable will be 816 FilePath *logParent = logPath.parent(); 817 FilePath uninstallPath(*logParent, "gssetup.exe"); 818 819 // delete the gssetup executable 820 DeleteFile(uninstallPath.cString()); 821 822 // dispose of the parent directory information 823 delete logParent; 824 } 825 // if not, then overwrite the original log with the modified one 826 else 827 { // do nothing - should be changed already! 828 } 829 } 761 830 } 762 831 // install wizard … … 777 846 install.updateRegistry(); 778 847 install.updateProfiles(); 848 849 // the log will need reopening (probably failed initially) 850 install.reopenLog(); 851 852 // close log 853 install.closeLog(); 779 854 780 855 // do further actions
Note:
See TracChangeset
for help on using the changeset viewer.