Instructions for using the fs.fsyncsync method in node.js

  • 2020-03-30 04:36:52
  • OfStack

Method description:

Sync version of fsync(). Synchronize the disk cache.

Grammar:


fs.fsyncSync(fd)

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

Receiving parameters:

Fd        File descriptor.

Example:


var fs = require('fs');
fs.open('content.txt', 'a', function(err,fd){
 if(err){
  throw err;
 }
 console.log('file open');
 
 fs.fsyncSync(fd);
 
 fs.close(fd,function(err){
  if(err){
   throw err;
  }
  console.log('file closed');
 })
})

Source:


fs.fsyncSync = function(fd) {
  return binding.fsync(fd);
};


Related articles: