Instructions for the fs.fsyncSync method in node.js
- 2020-05-05 10:51:33
- OfStack
method description:
Synchronous version of fsync(). Synchronize the disk cache.
syntax:
fs.fsyncSync(fd)
Since this method belongs to the fs module, it is necessary to introduce the fs module (var fs= require(" fs "))
before using itreceive 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 code:
fs.fsyncSync = function(fd) {
return binding.fsync(fd);
};