What is `process.binding ('fs')` in `fs.js`?

At the top is fs.jsdisplayed process.binding('fs').

https://github.com/nodejs/node/blob/master/lib/fs.js#L10 :

const binding = process.binding('fs');

And then it is used as:

binding.open(pathModule._makeLong(path),
           stringToFlags(flag),
           0o666,
           req);

(At https://github.com/nodejs/node/blob/master/lib/fs.js#L303-L306 )

My question is:

  • What does it mean process.binding('fs')?
  • What is fshere (we are already in fs.js)?
  • Where can I find the source code binding.open? Is it Javascript code or c / C ++ code?
+4
source share
1 answer
  • process.binding() is the internal API used by node to get links to various C ++ bindings.
  • 'fs' process.binding('fs') ++ (src/node_file.cc node) fs.
  • , process.binding() ++, binding.open() .
+9

All Articles