[sword-cvs] sword/src/mgr installmgr.cpp,1.8,1.9

sword@www.crosswire.org sword@www.crosswire.org
Sun, 6 Jul 2003 19:50:07 -0700


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

Modified Files:
	installmgr.cpp 
Log Message:
no message

Index: installmgr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/mgr/installmgr.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** installmgr.cpp	7 Jul 2003 00:25:59 -0000	1.8
--- installmgr.cpp	7 Jul 2003 02:50:05 -0000	1.9
***************
*** 6,9 ****
--- 6,17 ----
   
  
+ // stupid hack to make untgz stuff compile
+ #define VCL
+ 
+ extern "C" {
+ #include <untgz.h>
+ }
+ 
+ 
  #include <installmgr.h>
  #include <filemgr.h>
***************
*** 308,312 ****
  }
  
! 
  int InstallMgr::FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
  	terminate = false;
--- 316,324 ----
  }
  
! SWMgr *InstallSource::getMgr() {
! 	if (!mgr)
! 		mgr = new SWMgr(localShadow.c_str());
! 	return mgr;
! }
  int InstallMgr::FTPCopy(InstallSource *is, const char *src, const char *dest, bool dirTransfer, const char *suffix) {
  	terminate = false;
***************
*** 551,554 ****
--- 563,600 ----
  }
  
+ 
+ void InstallMgr::refreshRemoteSource(InstallSource *is) {
+ 	DIR *dir;
+ 	struct dirent *ent;
+ 	ConfigEntMap::iterator entry;
+ 	SWBuf modDir;
+ 	SWBuf modFile;
+ 	SWBuf root = privatePath;
+ 	root += (SWBuf)"/" + is->source.c_str();
+ 	SWBuf target = root + "/mods.d";
+ 
+ 	if (dir = opendir(target.c_str())) {
+ 		rewinddir(dir);
+ 		while ((ent = readdir(dir))) {
+ 			if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
+ 				modFile = target;
+ 				modFile += "/";
+ 				modFile += ent->d_name;
+ 				remove(modFile.c_str());
+ 			}
+ 		}
+ 		closedir(dir);
+ 	}
+ 
+ 
+ 	SWBuf archive = root + "/mods.d.tar.gz";
+ 	if (!FTPCopy(is, "mods.d.tar.gz", archive.c_str(), false)) {
+ 		int fd = open(archive.c_str(), O_RDONLY|O_BINARY);
+ 		untargz(fd, root.c_str());
+ 		close(fd);
+ 	}
+ 	else	FTPCopy(is, "mods.d", target.c_str(), true, ".conf");
+ 	is->flush();
+ }
  
  SWORD_NAMESPACE_END