The FileSystemStats represents a particular FileSystemEntry's stats.
function FileSystemStats(options) {
var isFile = options.isFile;
this._isFile = isFile;
this._isDirectory = !isFile;
// in case of stats transferred over a node-domain,
// mtime will have JSON-ified value which needs to be restored
this._mtime = options.mtime instanceof Date ? options.mtime : new Date(options.mtime);
this._size = options.size;
// hash is a property introduced by brackets and it's calculated
// as a valueOf modification time -> calculate here if it's not present
this._hash = options.hash || this._mtime.valueOf();
var realPath = options.realPath;
if (realPath) {
if (!isFile && realPath[realPath.length - 1] !== "/") {
realPath += "/";
}
this._realPath = realPath;
}
}
// Add "isFile", "isDirectory", "mtime" and "size" getters
Object.defineProperties(FileSystemStats.prototype, {
"isFile": {
get: function () { return this._isFile; },
set: function () { throw new Error("Cannot set isFile"); }
},
"isDirectory": {
get: function () { return this._isDirectory; },
set: function () { throw new Error("Cannot set isDirectory"); }
},
"mtime": {
get: function () { return this._mtime; },
set: function () { throw new Error("Cannot set mtime"); }
},
"size": {
get: function () { return this._size; },
set: function () { throw new Error("Cannot set size"); }
},
"realPath": {
get: function () { return this._realPath; },
set: function () { throw new Error("Cannot set realPath"); }
}
});
Whether or not this is a stats object for a directory
FileSystemStats.prototype._isDirectory = false;
Whether or not this is a stats object for a file
FileSystemStats.prototype._isFile = false;