[sword-cvs] sword/src/mgr installmgr.cpp,1.12,1.13

sword@www.crosswire.org sword@www.crosswire.org
Wed, 16 Jul 2003 05:26:11 -0700


Update of /usr/local/cvsroot/sword/src/mgr
In directory www:/tmp/cvs-serv24686/src/mgr

Modified Files:
	installmgr.cpp 
Log Message:
Some very small optimizations


Index: installmgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/installmgr.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- installmgr.cpp	13 Jul 2003 07:14:48 -0000	1.12
+++ installmgr.cpp	16 Jul 2003 12:26:09 -0000	1.13
@@ -407,6 +407,9 @@
 	SWBuf buffer;
 	bool aborted = false;
 	bool cipher = false;
+	DIR *dir;
+	struct dirent *ent;
+	SWBuf modFile;
 
 
 	if (is)
@@ -461,11 +464,8 @@
 			}
 		}
 		else {	//copy all files in DataPath directory
-			DIR *dir;
-			struct dirent *ent;
 			ConfigEntMap::iterator entry;
 			SWBuf modDir;
-			SWBuf modFile;
 			SWBuf sourceOrig = sourceDir;
 
 			entry = module->second.find("DataPath");
@@ -527,37 +527,37 @@
 				}
 				sourceDir = sourceOrig;
 				sourceDir += "/mods.d/";
-				if (!aborted) {
-					if (dir = opendir(sourceDir.c_str())) {	// find and copy .conf file
-						rewinddir(dir);
-						while ((ent = readdir(dir))) {
-							if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
-								modFile = sourceDir;
-								modFile += ent->d_name;
-								SWConfig *config = new SWConfig(modFile.c_str());
-								if (config->Sections.find(modName) != config->Sections.end()) {
-									delete config;
-									SWBuf targetFile = destMgr->configPath; //"./mods.d/";
-									targetFile += "/";
-									targetFile += ent->d_name;
-									FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
-									if (cipher) {
+			}
+		}
+		if (!aborted) {
+			if (dir = opendir(sourceDir.c_str())) {	// find and copy .conf file
+				rewinddir(dir);
+				while ((ent = readdir(dir))) {
+					if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+						modFile = sourceDir;
+						modFile += ent->d_name;
+						SWConfig *config = new SWConfig(modFile.c_str());
+						if (config->Sections.find(modName) != config->Sections.end()) {
+							delete config;
+							SWBuf targetFile = destMgr->configPath; //"./mods.d/";
+							targetFile += "/";
+							targetFile += ent->d_name;
+							FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
+							if (cipher) {
 /*									
-										CipherForm->modName = modName;
-										CipherForm->confFile = targetFile;
-										if (CipherForm->ShowModal() == mrCancel) {
-											removeModule(modName);
-											aborted = true;
-										}
-*/											
-									}
+								CipherForm->modName = modName;
+								CipherForm->confFile = targetFile;
+								if (CipherForm->ShowModal() == mrCancel) {
+									removeModule(modName);
+									aborted = true;
 								}
-								else	delete config;
+*/											
 							}
 						}
-						closedir(dir);
+						else	delete config;
 					}
 				}
+				closedir(dir);
 			}
 		}
 		return (aborted) ? -1 : 0;