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

system.verbs.builtins.radio.webServer.getFileMimeType

on getFileMimeType (f) {
	<<Changes
		<<5/15/02; 4:20:21 PM by JES
			<<f is a folder, if it ends with the native system's path delimiter. By not calling file.isFolder, we can get the mime-type for files which may not exist yet.
	local (pc = file.getPathChar ());
	if f endsWith pc { //file.isfolder (f)
		return ("system/folder")};
	local (mimetype = "application/x-unknown");
	local (extension = string.nthfield (f, ".", string.countfields (f, ".")));
	local (adr = @user.webserver.prefs.ext2MIME.[extension]);
	if defined (adr^) {
		mimetype = adr^}
	else {
		if system.environment.isMac {
			local (adr = @user.webserver.prefs.type2MIME.[file.type (f)]);
			if defined (adr^) {
				mimetype = adr^}}};
	return (mimetype)}



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.