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

system.verbs.builtins.radio.backup.restore

on restore (backupFolder) {
	<<Changes
		<<1/14/03; 3:04:56 PM by JES
			<<When reading prefs tables, use table.xmlToTable instead of unpacking from a fat page.
		<<12/2/02; 12:49:12 PM by JES
			<<Added a call to radio.backup.restoreTemplates.
		<<11/26/02; 10:14:18 PM by JES
			<<Created.
	on readFile (partialpath) {
		if backupFolder beginsWith "http://" {
			return (tcp.httpReadUrl (backupFolder + partialpath))}
		else { //read from local filesystem
			local (f = backupFolder + string.replaceAll (partialPath, "/", file.getPathChar ()));
			return (file.readWholeFile (f))}};
	on importObject (partialpath) {
		if backupFolder beginsWith "http://" {
			table.xmlToTable (tcp.httpReadUrl (backupFolder + partialPath))}
		else { //read from local filesystem
			local (f = backupFolder + string.replaceAll (partialPath, "/", file.getPathChar ()));
			table.xmlToTable (file.readWholeFile (f))}};
		<<bundle //old .fttb-based importer
			<<local (filedata)
			<<if backupFolder beginsWith "http://"
				<<fatPages.getHttp (backupFolder + partialpath)
			<<else //read from local filesystem
				<<local (f = backupFolder + string.replaceAll (partialPath, "/", file.getPathChar ()))
				<<local (s = file.readWholeFile (f))
				<<local (atts)
				<<if not fatPages.getPageAtts (@s, @atts)
					<<fatPages.noObjectError (f)
				<<if not defined (atts.pageData)
					<<fatPages.noObjectError (path:f)
				<<local (adr = atts.adrPageData)
				<<fatPages.unpackOdbObject (@atts, adr, flEdit:false)
	
	local (files);
	radio.backup.readDirectory (readfile ("files.xml"), @files);
	radio.backup.restoreAllPrefs (@importObject, @files);
	
	radio.backup.restoreStories (@readfile, @files);
	radio.backup.restoreTemplates (@importObject);
	
	local (adrdata = radio.weblog.init ());
	radio.backup.restoreAllMonths (@readFile, @adrdata^.posts)};
bundle { //test code
	restore (user.radio.backup.prefs.folder)}



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.