[sword-svn] r3763 - trunk/src/mgr

scribe at crosswire.org scribe at crosswire.org
Sun Jul 26 04:29:46 EDT 2020


Author: scribe
Date: 2020-07-26 04:29:46 -0400 (Sun, 26 Jul 2020)
New Revision: 3763

Modified:
   trunk/src/mgr/filemgr.cpp
   trunk/src/mgr/ftplibftpt.cpp
Log:
Fixed error in windows code which left . and .. in the dirlist
Fixed ftplibftpt.cpp driver to use FileMgr to open files and write to them.

Modified: trunk/src/mgr/filemgr.cpp
===================================================================
--- trunk/src/mgr/filemgr.cpp	2020-07-25 16:32:16 UTC (rev 3762)
+++ trunk/src/mgr/filemgr.cpp	2020-07-26 08:29:46 UTC (rev 3763)
@@ -398,11 +398,14 @@
 	HANDLE findIterator = FindFirstFileW(wcharPath, &fileData);
 	if (findIterator != INVALID_HANDLE_VALUE) {
 		do {
-			struct DirEntry i;
-			i.name = wcharToUTF8(fileData.cFileName);
-			i.isDirectory = fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
-			i.size = FileMgr::getFileSize(basePath + i.name);
-			dirList.push_back(i);
+          	SWBuf dirEntName = wcharToUTF8(fileData.cFileName);
+			if (dirEntName != "." && dirEntName != "..") {
+				struct DirEntry i;
+				i.name = dirEntName;
+				i.isDirectory = fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
+				i.size = FileMgr::getFileSize(basePath + i.name);
+				dirList.push_back(i);
+			}
 		} while (FindNextFile(findIterator, &fileData) != 0);
 		FindClose(findIterator);
 	}

Modified: trunk/src/mgr/ftplibftpt.cpp
===================================================================
--- trunk/src/mgr/ftplibftpt.cpp	2020-07-25 16:32:16 UTC (rev 3762)
+++ trunk/src/mgr/ftplibftpt.cpp	2020-07-26 08:29:46 UTC (rev 3763)
@@ -19,7 +19,7 @@
  * General Public License for more details.
  *
  */
- 
+
 #include <stdio.h>
 #include <fcntl.h>
 
@@ -48,6 +48,12 @@
 		return (int)size;
 	}
 
+	static int my_filewriter(netbuf *nControl, void *buffer, size_t size, void *fd) {
+		FileDesc *output = (FileDesc *)fd;
+		output->write(buffer, size);
+		return (int)size;
+	}
+
 #if defined(__GNUC__)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
@@ -146,13 +152,15 @@
 	pd.sr = statusReporter;
 	pd.term = &term;
 	pd.totalSize = 0;
-
+     FileDesc *fd = 0;
 	if (destBuf) {
 		FtpOptions(FTPLIB_CALLBACK_WRITER, (long)&my_swbufwriter, ftpConnection);
 		FtpOptions(FTPLIB_CALLBACK_WRITERARG, (long)destBuf, ftpConnection);
 	}
 	else {
-		FtpOptions(FTPLIB_CALLBACK_WRITER, 0L, ftpConnection);
+     	fd = FileMgr::getSystemFileMgr()->open(outFile, FileMgr::CREAT|FileMgr::WRONLY);
+		FtpOptions(FTPLIB_CALLBACK_WRITER, (long)&my_filewriter, ftpConnection);
+		FtpOptions(FTPLIB_CALLBACK_WRITERARG, (long)fd, ftpConnection);
 	}
 
 	FtpOptions(FTPLIB_CALLBACK, (long)&my_fprogress, ftpConnection);
@@ -163,7 +171,7 @@
 //		SWLog::getSystemLog()->logDebug("getting test directory %s\n", sourcePath.c_str());
 //		FtpDir(NULL, sourcePath, ftpConnection);
 		SWLog::getSystemLog()->logDebug("getting real directory %s\n", sourcePath.c_str());
-		retVal = FtpDir(destBuf ? 0 : outFile.c_str(), sourcePath, ftpConnection) - 1;
+		retVal = FtpDir(0, sourcePath, ftpConnection) - 1;
 		SWLog::getSystemLog()->logDebug("got real directory %s to %s\n", sourcePath.c_str(), destBuf ? "*internal buffer*" : outFile.c_str());
 	}
 	else {
@@ -171,9 +179,9 @@
 		int size;
 		FtpSize(sourcePath, &size, FTPLIB_IMAGE, ftpConnection);
 		pd.totalSize = size;
-		retVal = FtpGet(destBuf ? 0 : outFile.c_str(), sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
+		retVal = FtpGet(0, sourcePath, FTPLIB_IMAGE, ftpConnection) - 1;
 	}
-
+     if (fd) FileMgr::getSystemFileMgr()->close(fd);
 	SWLog::getSystemLog()->logDebug("FTPLibFTPTransport - returning: %d\n", retVal);
 	return retVal;
 }



More information about the sword-cvs mailing list