Modules (181)

FileSystemStats

Description

The FileSystemStats represents a particular FileSystemEntry's stats.

Dependencies

This module has no dependencies

Classes

Constructor

FileSystemStats

options {isFile: boolean,mtime: Date,size: Number,realPath: ?string,hash: object}
    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"); }
        }
    });

Properties

Private

_hash

Consistency hash for a file

Type
object
Private
    FileSystemStats.prototype._hash = null;
Private

_isDirectory

Whether or not this is a stats object for a directory

Type
boolean
Private
    FileSystemStats.prototype._isDirectory = false;
Private

_isFile

Whether or not this is a stats object for a file

Type
boolean
Private
    FileSystemStats.prototype._isFile = false;
Private

_mtime

Modification time for a file

Type
Date
Private
    FileSystemStats.prototype._mtime = null;
Private

_realPath

The canonical path of this file or directory ONLY if it is a symbolic link, and null otherwise.

Type
?string
Private
    FileSystemStats.prototype._realPath = null;

    module.exports = FileSystemStats;
});
Private

_size

Size in bytes of a file

Type
Number
Private
    FileSystemStats.prototype._size = null;