init: function () {
this.cleanup();
+
+ if (services.bootstrap && !services.bootstrap.session)
+ services.bootstrap.session = {};
+ this.session = services.bootstrap ? services.bootstrap.session : {};
},
cleanup: function () {
let file = services.File();
if (path instanceof Ci.nsIFile)
- file = path.QueryInterface(Ci.nsIFile).clone();
+ file = path.clone();
else if (/file:\/\//.test(path))
- file = services["file:"]().getFileFromURLSpec(path);
+ file = services["file:"].getFileFromURLSpec(path);
else {
try {
let expandedPath = File.expandPath(path);
return self;
},
+ /**
+ * @property {nsIFileURL} Returns the nsIFileURL object for this file.
+ */
+ get URI() services.io.newFileURI(this),
+
/**
* Iterates over the objects in this directory.
*/
iterDirectory: function () {
if (!this.exists())
- throw Error("File does not exist");
+ throw Error(_("io.noSuchFile"));
if (!this.isDirectory())
- throw Error("Not a directory");
+ throw Error(_("io.eNotDir"));
for (let file in iter(this.directoryEntries))
yield File(file);
},
*
* @param {boolean} sort Whether to sort the returned directory
* entries.
- * @returns {nsIFile[]}
+ * @returns {[nsIFile]}
*/
readDirectory: function (sort) {
if (!this.isDirectory())
- throw Error("Not a directory");
+ throw Error(_("io.eNotDir"));
let array = [e for (e in this.iterDirectory())];
if (sort)
ofstream.init(this, mode, perms, 0);
try {
- if (callable(buf))
- buf(ofstream.QueryInterface(Ci.nsIOutputStream));
- else {
- var ocstream = getStream(0);
- ocstream.writeString(buf);
- }
+ var ocstream = getStream(0);
+ ocstream.writeString(buf);
}
- catch (e if callable(buf) && e.result == Cr.NS_ERROR_LOSS_OF_SIGNIFICANT_DATA) {
+ catch (e if e.result == Cr.NS_ERROR_LOSS_OF_SIGNIFICANT_DATA) {
+ ocstream.close();
ocstream = getStream("?".charCodeAt(0));
ocstream.writeString(buf);
return false;