LEQADA LEQADA - 1 year ago 97
Node.js Question

How isFile() function from fs.Stats class works?

There are no details about

function in documentation of fs.Stats class

How it works? What exactly it checks?

Answer Source

At the OS level an entry for a given entry is marked as either a file or a directory entry. That information does not appear to be directly surfaced in the fs.Stats data structure, but it is something that the isFile() method can tell from the fs.Stats data structure.

By looking at the code for fs.js in node.js, you can see these:

fs.Stats.prototype._checkModeProperty = function(property) {
  return ((this.mode & constants.S_IFMT) === property);

fs.Stats.prototype.isFile = function() {
  return this._checkModeProperty(constants.S_IFREG);

Which shows that the information is contained within the mode property of the fs.Stats data structure.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download