Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.file.locateFileIgnoringExtension
on locateFileIgnoringExtension (f, adrfoundfile) {
<<Changes
<<5/12/01; 2:01:02 PM by DW
<<Created. When the responder gets a file-not-found, it checks to see if the file exists without its extension. This allows us to give the user a choice of editors for files we serve. You can start a page using Notepad and then upgrade to an outliner and the links don't break. It's also possible to completely omit the extension in a link.
local (folder = file.folderfrompath (f));
local (basefname = string.lower (file.filefrompath (f)));
if basefname contains "." {
local (extension = string.nthfield (basefname, ".", string.countfields (basefname, ".")));
basefname = string.mid (basefname, 1, sizeof (basefname) - sizeof (extension) - 1);
basefname = string.lower (basefname)}; //PBS 06/15/01: case-insensitive
local (floop);
fileloop (floop in folder) {
if not (file.isFolder (floop)) { //PBS 06/15/01: don't check folders; check files only
if string.lower (string.popSuffix (file.filefrompath (floop))) == basefname { //PBS 06/15/01: popsuffix of filename, instead of beginsWith test
adrfoundfile^ = floop;
return (true)}}};
return (false)}
<<bundle //test code
<<local (f)
<<locateFileIgnoringExtension ("C:\\Program Files\\Radio UserLand\\www\\system\\help\\blogPost.txt", @f)
<<dialog.alert (f)
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.