Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.upstream.builtinDrivers.fileSystem.upstreamMultipleFiles

on upstreamMultipleFiles (fileslist, adrspec, adrresponse) {
	<<Changes
		<<5/15/02; 11:23:10 AM by JES
			<<If the file's mime-type does not begin with "text/", use file.writeWholeFile to write the file to disk, instead of file.writeTextFile.
		<<1/24/02; 7:49:12 PM by DW
			<<Created. 
	local (pc = file.getpathchar ());
	local (folder = adrspec^.folder);
	if not (folder endswith pc) {
		folder = folder + pc};
	msg ("Upstreaming " + sizeof (fileslist) + " files to " + folder + "...");
	local (urllist = {});
	for adrfile in fileslist {
		try {
			local (f = nameof (adrfile^));
			local (relativePath = adrfile^.relativePath);
			local (filetext = radio.upstream.getUpstreamText (f, @relativePath));
			local (fdest =  folder + string.replaceAll (relativePath, "/", pc));
			file.surefilepath (fdest);
			if radio.webserver.getFileMimeType (fdest) beginsWith "text/" {
				file.writetextfile (fdest, filetext)}
			else { //not a text file
				file.writewholefile (fdest, filetext)};
			adrfile^.upstream.flError = false;
			adrfile^.upstream.ctUploads++;
			local (url = adrspec^.url + relativePath);
			adrfile^.upstream.url = url;
			urllist [0] = url}
		else {
			adrfile^.upstream.flError = true;
			urllist [0] = ""}};
	new (tabletype, adrresponse);
	adrresponse^.urllist = urllist;
	adrresponse^.flerror = false;
	adrresponse^.message = "";
	msg ("")}
<<bundle //test code
	<<upstreamMultipleFiles (scratchpad.streams [1].files, scratchpad.streams [1].adrspec, @scratchpad.response)



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.