Thursday, February 10, 2011 at 1:00 PM.
system.verbs.builtins.fileSynch.synchDirectory
on synchDirectory (adrdata) {
<<Changes
<<2/10/11; 11:19:20 AM by DW
<<Created.
local (jsontext);
bundle { //generate jsontext
local (indentlevel = 0, adrfile, flnotfirst = false);
jsontext = "";
on add (s) {
jsontext = jsontext + string.filledstring ("\t", indentlevel) + s + "\r"};
on encode (s) {
return (string.multiplereplaceall (s, @json.data.replaceTable))};
add ("{"); indentlevel++;
add ("\"files\": ["); indentlevel++;
for adrfile in @adrdata^.files {
bundle { //add comma if not first
if flnotfirst {
add (",")};
flnotfirst = true};
add ("{"); indentlevel++;
add ("\"path\": \"" + encode (nameof (adrfile^)) + "\",");
add ("\"whenCreated\": \"" + date.netstandardstring (adrfile^.whenCreated) + "\",");
add ("\"whenLastUpload\": \"" + date.netstandardstring (adrfile^.whenLastUpload) + "\",");
add ("\"ctUploads\": \"" + adrfile^.ctuploads + "\",");
add ("\"url\": \"" + encode (adrfile^.url) + "\",");
add ("}"); indentlevel--};
add ("]"); indentlevel--;
add ("}"); indentlevel--};
bundle { //write file
local (path = adrdata^.prefs.rootpath + "directory.json");
s3.newobject (path, jsontext, type:"application/json")}};
bundle { //test code
synchDirectory (@user.fileSynch.synchPoints.["Amazon S3"])}
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.