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

system.verbs.builtins.radio.backup.restoreStories

on restoreStories (adrReadFileCallback, adrfiles) {
	<<Changes
		<<1/15/03; 4:52:47 PM by JES
			<<On MacOS, check the filename length before checking to see if the file exists.
		<<11/27/02; 1:27:43 AM by JES
			<<Created.
	local (adr, pc = file.getPathChar ());
	for adr in adrfiles {
		local (partialpath = nameOf (adr^));
		if string.lower (partialpath) beginsWith "stories" {
			local (f = user.radio.prefs.wwwFolder + string.replaceAll (partialPath, "/", pc));
			bundle { //ensure 31 character filename length on MacOS
				if system.environment.isMac {
					local (fname = file.fileFromPath (f));
					if sizeOf (fname) > 31 {
						local (ext = string.nthField (fname, '.', string.countFields (fname, '.')));
						fname = string.popSuffix (fname);
						fname = string.mid (fname, 1, 31 - (sizeOf (ext) + 1) );
						f = file.folderFromPath (f) + fname + "." + ext}}};
			file.sureFilePath (f);
			if file.exists (f) { //only replace the file if it's new or changed
				if file.modified (f) == adr^.modified and file.size (f) == adr^.size {
					continue}};
			file.writeWholeFile (f, adrReadFileCallback^ (partialPath));
			file.setCreated (f, adr^.created);
			file.setModified (f, adr^.modified)}}}



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.