[sword-svn] r3147 - in trunk: bindings include src/mgr

scribe at crosswire.org scribe at crosswire.org
Wed Mar 26 00:54:35 MST 2014


Author: scribe
Date: 2014-03-26 00:54:35 -0700 (Wed, 26 Mar 2014)
New Revision: 3147

Modified:
   trunk/bindings/flatapi.cpp
   trunk/include/flatapi.h
   trunk/src/mgr/filemgr.cpp
   trunk/src/mgr/installmgr.cpp
   trunk/src/mgr/remotetrans.cpp
Log:
Fixed a bug in flatapi c-tor SWMgr_newWithPath
Fixed debug output from warning to debug
Added missing InstallMgr_delete d-tor
Added correct error returns in FileMgr::copyDir and InstallMgr::installModule

Modified: trunk/bindings/flatapi.cpp
===================================================================
--- trunk/bindings/flatapi.cpp	2014-03-24 19:50:34 UTC (rev 3146)
+++ trunk/bindings/flatapi.cpp	2014-03-26 07:54:35 UTC (rev 3147)
@@ -949,7 +949,7 @@
 SWHANDLE SWDLLEXPORT org_crosswire_sword_SWMgr_newWithPath(const char *path) { 
 	SWBuf confPath = path;
 	if (!confPath.endsWith("/")) confPath.append('/');
-	SWBuf modsd = confPath.append("mods.d");
+	SWBuf modsd = confPath + "mods.d";
 	// be sure we have at least some config file already out there
 	if (!FileMgr::existsFile(modsd.c_str())) {
 		modsd.append("/globals.conf");
@@ -1293,6 +1293,17 @@
 
 /*
  * Class:     org_crosswire_sword_InstallMgr
+ * Method:    delete
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_InstallMgr_delete
+  (SWHANDLE hInstallMgr) {
+	HandleInstMgr *hinstMgr = (HandleInstMgr *)hInstallMgr;
+	if (hinstMgr) delete hinstMgr;
+}
+
+/*
+ * Class:     org_crosswire_sword_InstallMgr
  * Method:    setUserDisclaimerConfirmed
  * Signature: ()V
  */

Modified: trunk/include/flatapi.h
===================================================================
--- trunk/include/flatapi.h	2014-03-24 19:50:34 UTC (rev 3146)
+++ trunk/include/flatapi.h	2014-03-26 07:54:35 UTC (rev 3147)
@@ -444,6 +444,14 @@
 
 /*
  * Class:     org_crosswire_sword_InstallMgr
+ * Method:    delete
+ * Signature: ()V
+ */
+void SWDLLEXPORT org_crosswire_sword_InstallMgr_delete
+  (SWHANDLE hInstallMgr);
+
+/*
+ * Class:     org_crosswire_sword_InstallMgr
  * Method:    setUserDisclaimerConfirmed
  * Signature: ()V
  */

Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp	2014-03-24 19:50:34 UTC (rev 3146)
+++ trunk/src/mgr/filemgr.cpp	2014-03-26 07:54:35 UTC (rev 3147)
@@ -509,23 +509,24 @@
 int FileMgr::copyDir(const char *srcDir, const char *destDir) {
 	DIR *dir;
 	struct dirent *ent;
+	int retVal = 0;
 	if ((dir = opendir(srcDir))) {
 		rewinddir(dir);
-		while ((ent = readdir(dir))) {
+		while ((ent = readdir(dir)) && !retVal) {
 			if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
 				SWBuf srcPath  = (SWBuf)srcDir  + (SWBuf)"/" + ent->d_name;
 				SWBuf destPath = (SWBuf)destDir + (SWBuf)"/" + ent->d_name;
 				if (!isDirectory(srcPath.c_str())) {
-					copyFile(srcPath.c_str(), destPath.c_str());
+					retVal = copyFile(srcPath.c_str(), destPath.c_str());
 				}
 				else {
-					copyDir(srcPath.c_str(), destPath.c_str());
+					retVal = copyDir(srcPath.c_str(), destPath.c_str());
 				}
 			}
 		}
 		closedir(dir);
 	}
-	return 0;
+	return retVal;
 }
 
 

Modified: trunk/src/mgr/installmgr.cpp
===================================================================
--- trunk/src/mgr/installmgr.cpp	2014-03-24 19:50:34 UTC (rev 3146)
+++ trunk/src/mgr/installmgr.cpp	2014-03-26 07:54:35 UTC (rev 3147)
@@ -361,6 +361,7 @@
 		SWBuf dir = (SWBuf)is->directory.c_str();
 		removeTrailingSlash(dir);
 		dir += (SWBuf)"/" + src; //dont forget the final slash
+SWLog::getSystemLog()->logDebug("remoteCopy: dirTransfer: %s", dir.c_str());
 
 		retVal = trans->copyDirectory(urlPrefix, dir, dest, suffix);
 
@@ -393,6 +394,7 @@
 
 
 int InstallMgr::installModule(SWMgr *destMgr, const char *fromLocation, const char *modName, InstallSource *is) {
+	int retVal = 0;
 	SectionMap::iterator module, section;
 	ConfigEntMap::iterator fileBegin;
 	ConfigEntMap::iterator fileEnd;
@@ -449,14 +451,14 @@
 
 			if (!aborted) {
 				// DO THE INSTALL
-				while (fileBegin != fileEnd) {
+				while (fileBegin != fileEnd && !retVal) {
 					SWBuf sourcePath = sourceDir;
 					sourcePath += fileBegin->second.c_str();
 					SWBuf dest = destMgr->prefixPath;
 					removeTrailingSlash(dest);
 					dest += '/';
 					dest += fileBegin->second.c_str();
-					FileMgr::copyFile(sourcePath.c_str(), dest.c_str());
+					retVal = FileMgr::copyFile(sourcePath.c_str(), dest.c_str());
 
 					fileBegin++;
 				}
@@ -504,7 +506,7 @@
 				}
 				if (!aborted) {
 					SWBuf destPath = (SWBuf)destMgr->prefixPath + relativePath;
-					FileMgr::copyDir(absolutePath.c_str(), destPath.c_str());
+					retVal = FileMgr::copyDir(absolutePath.c_str(), destPath.c_str());
 				}
 				if (is) {		// delete tmp netCopied files
 //					mgr->deleteModule(modName);
@@ -516,7 +518,7 @@
 			SWBuf confDir = sourceDir + "mods.d/";
 			if ((dir = opendir(confDir.c_str()))) {	// find and copy .conf file
 				rewinddir(dir);
-				while ((ent = readdir(dir))) {
+				while ((ent = readdir(dir)) && !retVal) {
 					if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
 						modFile = confDir;
 						modFile += ent->d_name;
@@ -526,7 +528,7 @@
 							removeTrailingSlash(targetFile);
 							targetFile += "/";
 							targetFile += ent->d_name;
-							FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
+							retVal = FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
 							if (cipher) {
 								if (getCipherCode(modName, config)) {
 									SWMgr newDest(destMgr->prefixPath);
@@ -535,7 +537,7 @@
 								}
 								else {
 									config->Save();
-									FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
+									retVal = FileMgr::copyFile(modFile.c_str(), targetFile.c_str());
 								}
 							}
 						}
@@ -545,7 +547,7 @@
 				closedir(dir);
 			}
 		}
-		return (aborted) ? -1 : 0;
+		return (aborted) ? -9 : retVal;
 	}
 	return 1;
 }

Modified: trunk/src/mgr/remotetrans.cpp
===================================================================
--- trunk/src/mgr/remotetrans.cpp	2014-03-24 19:50:34 UTC (rev 3146)
+++ trunk/src/mgr/remotetrans.cpp	2014-03-26 07:54:35 UTC (rev 3147)
@@ -81,6 +81,7 @@
 
 vector<struct DirEntry> RemoteTransport::getDirList(const char *dirURL) {
 
+SWLog::getSystemLog()->logDebug("RemoteTransport::getDirList(%s)", dirURL);
 	vector<struct DirEntry> dirList;
 	
 	SWBuf dirBuf;
@@ -100,12 +101,12 @@
 				else if ((*end != 10) && (*end != 13))
 					break;
 			}
-			SWLog::getSystemLog()->logWarning("getDirList: parsing item %s(%d)\n", start, end-start);
+			SWLog::getSystemLog()->logDebug("getDirList: parsing item %s(%d)\n", start, end-start);
 			int status = ftpparse(&item, start, end - start);
 			// in ftpparse.h, there is a warning that name is not necessarily null terminated
 			SWBuf name;
 			name.append(item.name, item.namelen);
-			SWLog::getSystemLog()->logWarning("getDirList: got item %s\n", name.c_str());
+			SWLog::getSystemLog()->logDebug("getDirList: got item %s\n", name.c_str());
 			if (status && name != "." && name != "..") {
 				struct DirEntry i;
 				i.name = name;
@@ -124,6 +125,7 @@
 
 
 int RemoteTransport::copyDirectory(const char *urlPrefix, const char *dir, const char *dest, const char *suffix) {
+SWLog::getSystemLog()->logDebug("RemoteTransport::copyDirectory");
 	unsigned int i;
 	int retVal = 0;
 	
@@ -131,7 +133,7 @@
 	removeTrailingSlash(url);
 	url += '/';
 	
-	SWLog::getSystemLog()->logWarning("NetTransport: getting dir %s\n", url.c_str());
+	SWLog::getSystemLog()->logDebug("NetTransport: getting dir %s\n", url.c_str());
 	vector<struct DirEntry> dirList = getDirList(url.c_str());
 
 	if (!dirList.size()) {




More information about the sword-cvs mailing list