Instructions for the fs.chmodSync method in node.js

  • 2020-05-07 19:11:33
  • OfStack

method description:

A synchronized version of chmod(), which overwrites the read and write permissions of the file.

syntax:

fs.chmodSync(path, mode)

Since this method belongs to the fs module, the fs module (var fs = require(" fs ")) needs to be introduced before use.

receive parameter:

1. path               file path

2. mode           read and write permissions (e.g. 777)

example:


var fs = require('fs'),
 oldFilename = "./processId.txt";
fs.chmodSync(oldFilename, 777);

source code:


fs.chmodSync = function(path, mode) {
  nullCheck(path);
  return binding.chmod(pathModule._makeLong(path), modeNum(mode));
};


Related articles: