[sword-svn] r3166 - in branches/sword-1-7-x: . src/modules/common

greg.hellings at crosswire.org greg.hellings at crosswire.org
Wed Apr 16 21:08:45 MST 2014


Author: greg.hellings
Date: 2014-04-16 21:08:45 -0700 (Wed, 16 Apr 2014)
New Revision: 3166

Modified:
   branches/sword-1-7-x/
   branches/sword-1-7-x/src/modules/common/zverse.cpp
Log:
Merging r3104 - updated zverse error reporting



Property changes on: branches/sword-1-7-x
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:2989-2991,2997,3001-3004,3006,3010-3013,3015-3020,3026-3039,3045-3046,3048,3056,3058-3062,3067,3073,3077-3081,3085-3086,3091,3094,3097-3099,3102
   + /trunk:2989-2991,2997,3001-3004,3006,3010-3013,3015-3020,3026-3039,3045-3046,3048,3056,3058-3062,3067,3073,3077-3081,3085-3086,3091,3094,3097-3099,3102,3104

Modified: branches/sword-1-7-x/src/modules/common/zverse.cpp
===================================================================
--- branches/sword-1-7-x/src/modules/common/zverse.cpp	2014-04-17 04:07:57 UTC (rev 3165)
+++ branches/sword-1-7-x/src/modules/common/zverse.cpp	2014-04-17 04:08:45 UTC (rev 3166)
@@ -428,7 +428,11 @@
 {
 	char *path = 0;
 	char *buf = new char [ strlen (ipath) + 20 ];
+	char retVal = 0;
 	FileDesc *fd, *fd2;
+	__s32 offset = 0;
+	__s16 size = 0;
+	VerseKey vk;
 
 	stdstr(&path, ipath);
 
@@ -438,69 +442,81 @@
 	sprintf(buf, "%s/ot.%czs", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
 	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd->getFd();
+	if (fd->getFd() < 1) goto erroropen1;
 	FileMgr::getSystemFileMgr()->close(fd);
 
 	sprintf(buf, "%s/nt.%czs", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
 	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd->getFd();
+	if (fd->getFd() < 1) goto erroropen1;
 	FileMgr::getSystemFileMgr()->close(fd);
 
 	sprintf(buf, "%s/ot.%czz", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
 	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd->getFd();
+	if (fd->getFd() < 1) goto erroropen1;
 	FileMgr::getSystemFileMgr()->close(fd);
 
 	sprintf(buf, "%s/nt.%czz", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
-	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd2->getFd();
+	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
+	if (fd->getFd() < 1) goto erroropen1;
 	FileMgr::getSystemFileMgr()->close(fd);
 
 	sprintf(buf, "%s/ot.%czv", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
 	fd = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd->getFd();
+	if (fd->getFd() < 1) goto erroropen1;
 
 	sprintf(buf, "%s/nt.%czv", path, uniqueIndexID[blockBound]);
 	FileMgr::removeFile(buf);
 	fd2 = FileMgr::getSystemFileMgr()->open(buf, FileMgr::CREAT|FileMgr::WRONLY, FileMgr::IREAD|FileMgr::IWRITE);
-	fd2->getFd();
+	if (fd2->getFd() < 1) goto erroropen2;
 
-	VerseKey vk;
 	vk.setVersificationSystem(v11n);
 	vk.setIntros(true);
 
-	__s32 offset = 0;
-	__s16 size = 0;
 	offset = archtosword32(offset);
 	size   = archtosword16(size);
 
 	for (vk = TOP; !vk.popError(); vk++) {
 		if (vk.getTestament() < 2) {
-			fd->write(&offset, 4);	//compBufIdxOffset
-			fd->write(&offset, 4);
-			fd->write(&size, 2);
+			if (fd->write(&offset, 4) != 4) goto writefailure;	//compBufIdxOffset
+			if (fd->write(&offset, 4) != 4) goto writefailure;
+			if (fd->write(&size, 2) != 2) goto writefailure;
 		}
 		else {
-			fd2->write(&offset, 4);	//compBufIdxOffset
-			fd2->write(&offset, 4);
-			fd2->write(&size, 2);
+			if (fd2->write(&offset, 4) != 4) goto writefailure;	//compBufIdxOffset
+			if (fd2->write(&offset, 4) != 4) goto writefailure;
+			if (fd2->write(&size, 2) != 2) goto writefailure;
 		}
 	}
 	fd2->write(&offset, 4);	//compBufIdxOffset
 	fd2->write(&offset, 4);
 	fd2->write(&size, 2);
 
+	goto cleanup;
+
+erroropen1:
+	retVal = -1;
+	goto cleanup1;
+
+erroropen2:
+	retVal = -1;
+	goto cleanup;
+
+writefailure:
+	retVal = -2;
+
+cleanup:
+	FileMgr::getSystemFileMgr()->close(fd2);
+cleanup1:
 	FileMgr::getSystemFileMgr()->close(fd);
-	FileMgr::getSystemFileMgr()->close(fd2);
 
 	delete [] path;
 	delete [] buf;
 	
-	return 0;
+	return retVal;
 }
 
 




More information about the sword-cvs mailing list