2 * (C) Copyright 2004-2007 Shawn Betts
3 * (C) Copyright 2007-2008 John J. Foerch
4 * (C) Copyright 2007-2008 Jeremy Maitin-Shepard
6 * Use, modification, and distribution are subject to the terms specified in the
10 function load_rc_file(file)
14 if (typeof file == "string")
19 subscript_loader.loadSubScript("file://" + name, conkeror);
25 function load_rc_directory (file_o) {
26 var entries = file_o.directoryEntries;
28 while (entries.hasMoreElements ()) {
29 var entry = entries.getNext ();
30 entry.QueryInterface (Ci.nsIFile);
31 if (entry.leafName.match(/^[^.].*\.js$/i)) {
35 files.sort(function (a, b) {
36 if (a.leafName < b.leafName) {
38 } else if (a.leafName > b.leafName) {
44 for (var i = 0; i < files.length; i++) {
45 load_rc_file(files[i]);
51 * path_s: string path to load. may be a file, a directory, or null.
52 * if it is a file, that file will be loaded. if it is a directory,
53 * all `.js' files in that directory will be loaded. if it is null,
54 * the preference `conkeror.rcfile' will be read for the default.
56 function load_rc(path_s)
60 if (pref_has_user_value("conkeror.rcfile")) {
61 var rcfile = get_pref("conkeror.rcfile");
67 var default_rc = get_home_directory();
68 default_rc.appendRelativePath(".conkerorrc");
69 if (default_rc.exists())
70 path_s = default_rc.path;
76 var file_o = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
77 file_o.initWithPath(path_s);
78 if (file_o.isDirectory()) {
79 load_rc_directory (file_o);
81 load_rc_file (path_s);