Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Extra libraries, Code snippets, applications etc. » U++ users applications in progress and useful code snippets, including reference examples! » Uploading files via FTP
Uploading files via FTP [message #6421] Sat, 11 November 2006 17:58 Go to previous message
mirek is currently offline  mirek
Messages: 14058
Registered: November 2005
Ultimate Member
This nice little piece of U++ code is responsible for "syncing" www.ultimatepp.org content:

	Vector<String> upload;
	{
		FindFile ff(AppendFileName(targetdir, "*.*"));
		while(ff) {
			if(ff.IsFile()) {
				String s = LoadFile(AppendFileName(targetdir, ff.GetName()));
				String f = AppendFileName(diffdir, ff.GetName());
				if(LoadFile(f) != s) {
					upload.Add(ff.GetName());
				}
			}
			ff.Next();
		}
	}
	if(upload.GetCount()) {
		Progress pi;
		pi.SetTotal(upload.GetCount());
		FtpClient ftp;
		pi.Create();
		pi.SetText("connecting...");
		if(!ftp.Connect(GetIniKey("UppFtp"), GetIniKey("UppFtpUsr"), GetIniKey("UppFtpPwd"), true)) {
			Exclamation("Unable to connect!" + ftp.GetError());
			return;
		}
		if(!ftp.Cd("www")) {
			Exclamation("Unable to 'cd www'");
			return;
		}
		for(int i = 0; i < upload.GetCount(); i++) {
			pi.SetText(upload[i]);
			if(pi.StepCanceled())
				break;
			String s = LoadFile(AppendFileName(targetdir, upload[i]));
			if(!ftp.Save(GetFileName(upload[i]), s)) {
				Exclamation("FTP error (file upload): " + ftp.GetError());
				return;
			}
			SaveFile(AppendFileName(diffdir, ff.GetName()), s);
		}
	}


Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Hexbombs
Next Topic: HomeBudget example bug
Goto Forum:
  


Current Time: Fri Oct 11 04:30:13 CEST 2024

Total time taken to generate the page: 0.02519 seconds