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


on write (adrData, path, type, creator, creationDate, adrPageTable, adrStorage) {
	<<This script is called whenever a file needs to be written somewhere.
			<<adrData: this is the address of data the file should contain.
			<<path: path is a relative, /-delimited path.
				<<It's relative to the ftpSite^.folder.
			<<type: the file type.
			<<creator: the file creator.
			<<creationDate: should be the creation data of the file.
			<<adrPageTable: the address of the current page data table.
			<<adrStorage: the address of private storage for this file writer for this session.
		<<This script doesn't have to write the file immediately --
			<<it could defer writing until the shutdown script is called.
		<<but it does.
			<<5/1/03; 10:34:34 PM by EDS
	if path beginsWith '/' {
		<<the site root directory ends with a /, so pop it from the rest of the path.
		path = string.mid(path,2,infinity)};
	try {
		if defined(adrStorage^.adrConnectionTable) {
			tcp.ftp.writeFile(adrStorage^.adrConnectionTable, adrdata^, adrStorage^.siteRootDirectory + path)}
		else {
			scriptError("There is no open ftp connection in filewriters.ftp.write")}}
	else {
		scriptError("Error in filewriters.ftp.write: " + tryError)};

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.