Method description:
Synchronous version of fsync(). Synchronize disk cache.
grammar:
The code copy is as follows:
fs.fsyncSync(fd)
Since this method belongs to the fs module, it is necessary to introduce the fs module before use (var fs= require("fs") )
Receive parameters:
fd file descriptor.
example:
The code copy is as follows:
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:
The code copy is as follows:
fs.fsyncSync = function(fd) {
return binding.fsync(fd);
};