Bug 776259 - Serialize file info. r=froydnj

This commit is contained in:
David Rajchenbach-Teller 2012-08-18 12:26:35 -04:00
parent fe2c20fbb6
commit d823deabd9
2 changed files with 39 additions and 21 deletions

View File

@ -667,16 +667,7 @@
* @type {number}
*/
get size() {
delete this.size;
let size;
try {
size = OS.Shared.projectValue(this._st_size);
} catch(x) {
LOG("get size error", x);
size = NaN;
}
Object.defineProperty(this, "size", { value: size });
return size;
return exports.OS.Shared.Type.size_t.importFromC(this._st_size);
},
/**
* The date of creation of this file
@ -716,22 +707,38 @@
* Return the Unix owner of this file.
*/
get unixOwner() {
return this._st_uid;
return exports.OS.Shared.Type.uid_t.importFromC(this._st_uid);
},
/**
* Return the Unix group of this file.
*/
get unixGroup() {
return this._st_gid;
return exports.OS.Shared.Type.gid_t.importFromC(this._st_gid);
},
/**
* Return the Unix mode of this file.
*/
get unixMode() {
return this._st_mode & MODE_MASK;
return exports.OS.Shared.Type.mode_t.importFromC(this._st_mode & MODE_MASK);
}
};
/**
* Return a version of an instance of File.Info that can be sent
* from a worker thread to the main thread. Note that deserialization
* is asymmetric and returns an object with a different implementation.
*/
File.Info.toMsg = function toMsg(stat) {
if (!stat instanceof File.Info) {
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
}
let serialized = {};
for (let key in File.Info.prototype) {
serialized[key] = stat[key];
}
return serialized;
};
/**
* Fetch the information on a file.
*

View File

@ -658,14 +658,8 @@
* @type {number}
*/
get size() {
try {
return OS.Shared.projectValue(
ctypes.uint64_t("" +
this._nFileSizeHigh +
this._nFileSizeLow));
} catch (x) {
return NaN;
}
let value = ctypes.UInt64.join(this._nFileSizeHigh, this._nFileSizeLow);
return exports.OS.Shared.Type.uint64_t.importFromC(value);
},
/**
* The date of creation of this file
@ -708,6 +702,23 @@
}
};
/**
* Return a version of an instance of File.Info that can be sent
* from a worker thread to the main thread. Note that deserialization
* is asymmetric and returns an object with a different implementation.
*/
File.Info.toMsg = function toMsg(stat) {
if (!stat instanceof File.Info) {
throw new TypeError("parameter of File.Info.toMsg must be a File.Info");
}
let serialized = {};
for (let key in File.Info.prototype) {
serialized[key] = stat[key];
}
return serialized;
};
/**
* Fetch the information on a file.
*