[Jslib] Error: DirUtils is not defined

tharpa nevermind at noyb.net
Thu Dec 7 06:41:51 PST 2006




Pete Collins wrote:> tharpa wrote:> >> Error: DirUtils is not defined>> 
Source File: chrome://jsliblive/content/cs251.js>> Line: 13>> >> Any 
suggestions?>> >> >> >> > can you provide a snip of you code for 
testing?Line 13 is:    	var du = new DirUtils; cs251.js in its entirety is: 
var cs251SubDir = "/cs251";
var cs251LinkFile = "/cs251Links.dat";
var cs251FriendsFile = "/cs251Friends.txt";
var cs251ImportFile = "/cs251Import.txt";


function create251Directory() {
	alert("test");
// this function will create the cs251 subdirectory in the
	// user's profile directory.
	// Store application data, link files here.
	useObj = true;
	var du = new DirUtils;
	var d = du.getPrefsDir();

	if(d != null) {
		var cs251Path = d + cs251SubDir;

		var cs251DirHandle = new Dir(cs251Path);

		if(!cs251DirHandle.exists()) {
			// directory doesn't exist, so create it
			cs251DirHandle.create();
		}
	}
}

function create251LinksFile() {
	// create the links file that will contain the annotated
	// rss feeds imported from wizz

	var du = new DirUtils;
	var d = du.getPrefsDir();

	var cs251Path = d + cs251SubDir;

	var LinksDatFile = cs251Path + cs251LinkFile;

	var datFile = new File(LinksDatFile);

	if(!datFile.exists()) {
		// Links file doesn't exist, so create it

		datFile.create();
	}
}

function create251FriendsFile() {
	// create the friends file in the cs251 directory
	var du = new DirUtils;
	var d = du.getPrefsDir();

	var cs251Path = d + cs251SubDir;

	var FriendsDatFile = cs251Path + cs251FriendsFile;

	var datFile = new File(FriendsDatFile);

	if(!datFile.exists()) {
		// Friends File doesn't exist, so create it

		datFile.create();
	}
}


function importBookmarksFile() {
	// read the user's bookmarks file and find all the rss feeds
	// write them out to a temporary file for annotation later


	var du = new DirUtils;
    var bkmks = du.getBookmarks();
    var bkmksFile = new File(bkmks);
    bkmksFile.open();

	var PrefsDir = du.getPrefsDir();

    var datFileName = PrefsDir + cs251SubDir + cs251ImportFile;

    var datFile = new File(datFileName);

    if(!datFile.exists()) {
        datFile.create();
    }

    datFile.open("w");
    var data = bkmksFile.readAllLines();

    for(key in data) {
        // loop through all bookmarks.
        // save parts only of the ones that match "rss"

        if(data[key].search(/rss/i) != -1) {
            if(data[key].search(/HREF/) != -1) {

                // regex to pull the url and the title from the link line
                // we don't want the other stuff from that line
                // javascript does weird things with angle brackets, so the 
end
                // of this is a bit dumb, with ....

                var url = /(\w+):\/\/([\w.]+)\/(\S*)" ADD_DATE=.* 
ID=.*>(.*)..../;
                var result = data[key].match(url);

                if(result != null) {
                    var myLink = result[1] + "://" + result[2] + "/" + 
result[3] + "-|-" + result[4];
                    datFile.write(myLink);
                } else {
                    datFile.write("error");
                }

                datFile.write("\n");
            } // endif
        } //endif
    } // endfor

    datFile.close();
    bkmksFile.close();
}
> > Thanks> > --peteThank you, Pete! 




More information about the Jslib mailing list