[sword-svn] r3813 - in trunk: bindings/Android/SWORD include src/mgr src/modules/common

scribe at crosswire.org scribe at crosswire.org
Sat Oct 17 07:52:15 EDT 2020


Author: scribe
Date: 2020-10-17 07:52:15 -0400 (Sat, 17 Oct 2020)
New Revision: 3813

Modified:
   trunk/bindings/Android/SWORD/build.gradle
   trunk/include/zipcomprs.h
   trunk/src/mgr/curlftpt.cpp
   trunk/src/mgr/curlhttpt.cpp
   trunk/src/mgr/ftplibftpt.cpp
   trunk/src/mgr/installmgr.cpp
   trunk/src/modules/common/zipcomprs.cpp
Log:
A bit more work on making it easier to use SWORD in a threadsafe manner.


Modified: trunk/bindings/Android/SWORD/build.gradle
===================================================================
--- trunk/bindings/Android/SWORD/build.gradle	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/bindings/Android/SWORD/build.gradle	2020-10-17 11:52:15 UTC (rev 3813)
@@ -8,7 +8,7 @@
         
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:4.0.1'
+        classpath 'com.android.tools.build:gradle:4.0.2'
         
 
         // NOTE: Do not place your application dependencies here; they belong

Modified: trunk/include/zipcomprs.h
===================================================================
--- trunk/include/zipcomprs.h	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/include/zipcomprs.h	2020-10-17 11:52:15 UTC (rev 3813)
@@ -41,7 +41,7 @@
 	virtual void encode(void);
 	virtual void decode(void);
 
-	static char unTarGZ(FileDesc *fd, const char *destPath);
+	static char unTarGZ(int fd, const char *destPath);
 };
 
 SWORD_NAMESPACE_END

Modified: trunk/src/mgr/curlftpt.cpp
===================================================================
--- trunk/src/mgr/curlftpt.cpp	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/src/mgr/curlftpt.cpp	2020-10-17 11:52:15 UTC (rev 3813)
@@ -55,7 +55,7 @@
 
 
 	static int my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
-		struct FtpFile *out=(struct FtpFile *)stream;
+		struct FtpFile *out = (struct FtpFile *)stream;
 		if (out && !out->fd && !out->destBuf) {
 			/* open file for writing */
 			out->fd = FileMgr::createPathAndFile(out->filename);

Modified: trunk/src/mgr/curlhttpt.cpp
===================================================================
--- trunk/src/mgr/curlhttpt.cpp	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/src/mgr/curlhttpt.cpp	2020-10-17 11:52:15 UTC (rev 3813)
@@ -39,17 +39,17 @@
 
 	struct FtpFile {
 		const char *filename;
-		FileDesc *stream;
+		int fd;
 		SWBuf *destBuf;
 	};
 
 
 	static int my_httpfwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
-		struct FtpFile *out=(struct FtpFile *)stream;
-		if (out && !out->stream && !out->destBuf) {
+		struct FtpFile *out = (struct FtpFile *)stream;
+		if (out && !out->fd && !out->destBuf) {
 			/* open file for writing */
-			out->stream=FileMgr::getSystemFileMgr()->open(out->filename, FileMgr::CREAT|FileMgr::WRONLY);
-			if (!out->stream || out->stream->getFd() < 0)
+			out->fd = FileMgr::createPathAndFile(out->filename);
+			if (out->fd < 0)
 				return -1; /* failure, can't open file to write */
 		}
 		if (out->destBuf) {
@@ -58,7 +58,7 @@
 			memcpy(out->destBuf->getRawData()+s, buffer, size*nmemb);
 			return (int)nmemb;
 		}
-		return (int)out->stream->write(buffer, size *nmemb);
+		return (int)FileMgr::write(out->fd, buffer, size * nmemb);
 	}
 
 
@@ -174,8 +174,8 @@
 		}
 	}
 
-	if (ftpfile.stream)
-		FileMgr::getSystemFileMgr()->close(ftpfile.stream); /* close the local file */
+	if (ftpfile.fd > 0)
+		FileMgr::closeFile(ftpfile.fd); /* close the local file */
 
 	return retVal;
 }

Modified: trunk/src/mgr/ftplibftpt.cpp
===================================================================
--- trunk/src/mgr/ftplibftpt.cpp	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/src/mgr/ftplibftpt.cpp	2020-10-17 11:52:15 UTC (rev 3813)
@@ -49,8 +49,8 @@
 	}
 
 	static int my_filewriter(netbuf *nControl, void *buffer, size_t size, void *fd) {
-		FileDesc *output = (FileDesc *)fd;
-		output->write(buffer, size);
+		int output = (int)fd;
+		write(output, buffer, size);
 		return (int)size;
 	}
 
@@ -153,13 +153,13 @@
 	pd.sr = statusReporter;
 	pd.term = &term;
 	pd.totalSize = 0;
-	FileDesc *fd = 0;
+	int fd = 0;
 	if (destBuf) {
 		FtpOptions(FTPLIB_CALLBACK_WRITER, (long)&my_swbufwriter, ftpConnection);
 		FtpOptions(FTPLIB_CALLBACK_WRITERARG, (long)destBuf, ftpConnection);
 	}
 	else {
-		fd = FileMgr::getSystemFileMgr()->open(outFile, FileMgr::CREAT|FileMgr::WRONLY);
+		fd = FileMgr::createPathAndFile(outFile);
 		FtpOptions(FTPLIB_CALLBACK_WRITER, (long)&my_filewriter, ftpConnection);
 		FtpOptions(FTPLIB_CALLBACK_WRITERARG, (long)fd, ftpConnection);
 	}
@@ -182,7 +182,7 @@
 		pd.totalSize = size;
 		retVal = FtpGet(0, sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
 	}
-	if (fd) FileMgr::getSystemFileMgr()->close(fd);
+	if (fd > 0) FileMgr::closeFile(fd);
 	SWLog::getSystemLog()->logDebug("FTPLibFTPTransport - returning: %d\n", retVal);
 	return retVal;
 }

Modified: trunk/src/mgr/installmgr.cpp
===================================================================
--- trunk/src/mgr/installmgr.cpp	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/src/mgr/installmgr.cpp	2020-10-17 11:52:15 UTC (rev 3813)
@@ -566,9 +566,9 @@
 
 	errorCode = remoteCopy(is, "mods.d.tar.gz", archive.c_str(), false);
 	if (!errorCode) { //sucessfully downloaded the tar,gz of module configs
-		FileDesc *fd = FileMgr::getSystemFileMgr()->open(archive.c_str(), FileMgr::RDONLY);
+		int fd = FileMgr::openFileReadOnly(archive.c_str());
 		ZipCompress::unTarGZ(fd, root.c_str());
-		FileMgr::getSystemFileMgr()->close(fd);
+		FileMgr::closeFile(fd);
 	}
 	else if (errorCode > -2)	// don't try the next attempt on connection error or user requested termination
 #endif

Modified: trunk/src/modules/common/zipcomprs.cpp
===================================================================
--- trunk/src/modules/common/zipcomprs.cpp	2020-10-15 17:32:41 UTC (rev 3812)
+++ trunk/src/modules/common/zipcomprs.cpp	2020-10-17 11:52:15 UTC (rev 3813)
@@ -373,10 +373,10 @@
 }
 
 
-char ZipCompress::unTarGZ(FileDesc *fd, const char *destPath) {
+char ZipCompress::unTarGZ(int fd, const char *destPath) {
 	gzFile	f;
 
-	f = gzdopen(fd->getFd(), "rb");
+	f = gzdopen(fd, "rb");
 	if (f == NULL) {
 		SWLog::getSystemLog()->logError("Couldn't gzopen file");
 		return 1;



More information about the sword-cvs mailing list