Monday, November 08, 2010 at 12:02 AM.
system.verbs.builtins.file.sureFolder
on sureFolder (path) {
if sys.os () contains "Win" {
if (sizeof (path) == 2) and string.isAlpha (path [1]) {
return (true)}};
try {
if file.isFolder (path) { <<it exists and it's a folder: it's cool.
return (true)}}
else { <<error: file doesn't exist, try to create folder
try {
return (file.newFolder (path))}
else { <<11/2/97 at 6:09:13 AM by DW
local (s = string.nthField (tryError, "\r", 1));
scriptError ("Couldn't create the folder \"" + path + "\", because \"" + s + "\"")}};
<<file existed, but wasn't a folder: error
scriptError ("Couldn't create the folder \"" + path + "\", because \"" + file.fileFromPath (path) + "\" is an existing file.")}
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.