[sword-svn] r93 - trunk/src/Installer_BC

bdrake at www.crosswire.org bdrake at www.crosswire.org
Fri Feb 8 08:58:39 MST 2008


Author: bdrake
Date: 2008-02-08 08:58:38 -0700 (Fri, 08 Feb 2008)
New Revision: 93

Modified:
   trunk/src/Installer_BC/SRInstallMGR.cpp
Log:
Problem fixed in destruction of local mods.d and modules on exit.  Both directories are now properly removed.

Modified: trunk/src/Installer_BC/SRInstallMGR.cpp
===================================================================
--- trunk/src/Installer_BC/SRInstallMGR.cpp	2008-02-06 14:23:58 UTC (rev 92)
+++ trunk/src/Installer_BC/SRInstallMGR.cpp	2008-02-08 15:58:38 UTC (rev 93)
@@ -394,7 +394,11 @@
 	exit (-1);
 		}
 	RAPIINIT ri = { sizeof(RAPIINIT) };
-	if ( SUCCEEDED(CeRapiInitEx(&ri))) {
+	if (!SUCCEEDED(CeRapiInitEx(&ri))) {
+				FXMessageBox::error(this,MBOX_OK,"CeRapiInit failed","Sorry, I could not connect to your mobile device");
+		CeRapiUninit();
+		exit (-1);
+    }
 	// wait for 10 seconds for the connection...
 	if ( (WaitForSingleObject(ri.heRapiInit, 10000) == WAIT_OBJECT_0) &&
 		SUCCEEDED(ri.hrRapiInit) ) {
@@ -461,11 +465,12 @@
 		CloseHandle( pi.hThread );
 		n=0;
 		hFile = FindFirstFile(TEXT("mods.d\\*.conf"), &FileInformation);
-		if(hFile != INVALID_HANDLE_VALUE)
-		{
+		if(hFile == INVALID_HANDLE_VALUE) {
+		FXMessageBox::error(this,MBOX_OK,"Process failed","Sorry, I could not open a\nfile in the mods.d directory.");
+		exit (-1);
+		}
 		do { // each .conf file in mods.d comes here with name etc
 		// START this pass storing .conf file name
-
 			char mPath[MAX_PATH];
 			strcpy (mPath, FileInformation.cFileName);
 			int len = strlen(mPath) + 1;    // how much space is needed
@@ -530,6 +535,9 @@
 				closedir(mods);
 				mods = NULL; }
 		  }while(FindNextFile(hFile, &FileInformation) == TRUE);
+		if (hFile){
+			FindClose(hFile);
+			hFile = NULL;  
 		newConfs[n] = 0;
 		}
 // removeModule (TEXT("phillips.conf")); // for debug
@@ -552,44 +560,24 @@
 			FindClose (modDir);
 			modDir = NULL;
 		} 	// Close handles
-		if (hFile){
-			FindClose(hFile);
-			hFile = NULL;
-		}
+
 		CeRapiUninit();
 		// TODO delete the two Conf arrays
-		// now remove all the files from the pc
-		//killFiles("mods.d");
-		//RemoveDirectory("mods.d");
-		//killFiles("modules");
-		//killFiles("modules"); // to remove empty directories
-		// RemoveDirectory("modules");
-		//return (swordPathString);
-		} // if ( (WaitForSingleObject(ri.heRapiInit .....
+	} // if ( SUCCEEDED(CeRapiInitEx
 	else {
-		FXMessageBox::error(this,MBOX_OK,"CeRapiInit failed","Sorry, I could not connect to your mobile device");
+		FXMessageBox::error(this,MBOX_OK,"rapiinit failed","Sorry, I could not connect to\nyour mobile device.");
 		CeRapiUninit();
 		exit (-1);
- //		Application::Exit();
-
 		}
-     if ( CeRapiInit() != E_FAIL ) {
-		}
-	else {
-		FXMessageBox::error(this,MBOX_OK,"CeRapiInit failed","Sorry, I could not connect to your mobile device");
-		CeRapiUninit();
-		exit (-1);
-		}
-	} // if ( SUCCEEDED(CeRapiInitEx
+ DeleteDirectory("mods.d");
+ DeleteDirectory("modules");
  exit (0);
  return 0; // to avoid the warning ....
 }
 
 // Here we begin
 int main(int argc,char *argv[]){
-  DeleteDirectory("mods.d");
-  DeleteDirectory("modules");
-  // Make application
+   // Make application
   FXApp application("SRInstallMGR","FoxVersion");
   // Start app
   application.init(argc,argv);




More information about the sword-cvs mailing list