Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.file.getFileAttributes
on getFileAttributes (f, adradrtable) { <<Changes <<3/3/02; 4:00:28 AM by JES <<Properly handle running directives in files which have unix-style line-endings. <<2/11/02; 5:30:29 PM by JES <<If adrcache^.upstream is not defined, create it. <<11/28/01; 6:20:06 PM by DW <<No longer initialize or save adrcache^.filetext. <<No longer cache outlineAsString. <<adrcache^.outlineAsString = string (adrcache^.outline) local (adrcache = @user.radio.settings.files.[f]); local (datezero = date (0)); if not defined (adrcache^) { new (tabletype, adrcache); adrcache^.hits = 0; adrcache^.mimetype = "text/plain"; adrcache^.size = 0; adrcache^.created = datezero; adrcache^.modified = datezero; bundle { //init title local (fname = file.filefrompath (f)); if file.isfolder (f) { fname = string.delete (fname, sizeof (fname), 1)}; adrcache^.title = fname}}; if not defined (adrcache^.upstream) { //init upstream sub-table local (adrupstream = @adrcache^.upstream); new (tabletype, adrupstream); adrupstream^.ctUploads = 0; adrupstream^.flError = false; adrupstream^.url = ""; adrupstream^.whenLastUploaded = datezero}; if defined (adrcache^) { if file.modified (f) == adrcache^.modified { adradrtable^ = adrcache; return (true)}}; local (mimetype = radio.webserver.getfilemimetype (f)); adradrtable^ = adrcache; //this is returned try { adrcache^.mimetype = mimetype; adrcache^.created = file.created (f); adrcache^.modified = file.modified (f); if file.isfolder (f) { local (ctfiles = 0); adrcache^.flFolder = true; fileloop (subf in f) { ctfiles++}; adrcache^.ctFiles = ctfiles} else { adrcache^.flFolder = false; case mimetype { "text/x-opml" { op.xmlToOutline (file.readwholefile (f), @adrcache^.outline); html.runOutlineDirectives (@adrcache^.outline, adrcache); if window.isOpen (@adrcache^.outline) { //work around a kernel bug window.close (@adrcache^.outline)}}; "text/plain" { local (filetext = file.readwholefile (f)); bundle { //check the first 500chars for a \n, and if we find one, convert to useable line endings local (first500 = string.mid (filetext, 1, 500)); if first500 contains "\n" { if not (first500 contains "\r\n") { filetext = string.replaceAll (filetext, "\n", "\r")}}}; html.runDirectives (filetext, adrcache)}}; adrcache^.size = file.size (f)}; return (true)} else { return (false)}} <<bundle //test code <<local (adr) <<getFileAttributes (user.radio.prefs.upstream.folder + "directory.opml", @adr) <<getFileAttributes (user.radio.prefs.upstream.folder + "index.txt", @adr) <<getFileAttributes (user.radio.prefs.upstream.folder + "#prefs.txt", @adr) <<dialog.alert (adr)
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.