// Returns null if it can't do it, false if there's an error, true if it saved OKfunction mozillaSaveFile(filePath, content){ if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) file.create(0, 0664); var out = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); out.init(file, 0x20 | 0x02, 00004,null); out.write(content, content.length); out.flush(); out.close(); return(true); } catch(e) { //alert("Exception while attempting to save\n\n" + e); return(false); } return(null);}
posted by charmston at 8:34 AM on March 19, 2006