| 
                         方法说明:  
同步版的 fsync() 。同步磁盘缓存。 
语法: 
复制代码 代码如下: 
fs.fsyncSync(fd) 
 
由于该方法属于fs模块,使用前需要引入fs模块(var fs= require(“fs”) ) 
接收参数: 
fdnbsp;nbsp;nbsp;nbsp; 文件描述符。 
例子: 
复制代码 代码如下: 
var fs = require('fs'); 
fs.open('content.txt', 'a', function(err,fd){ 
nbsp;if(err){ 
nbsp; throw err; 
nbsp;} 
nbsp;console.log('file open'); 
nbsp; 
nbsp;fs.fsyncSync(fd); 
nbsp; 
nbsp;fs.close(fd,function(err){ 
nbsp; if(err){ 
nbsp;nbsp; throw err; 
nbsp; } 
nbsp; console.log('file closed'); 
nbsp;}) 
}) 
 
源码: 
复制代码 代码如下: 
fs.fsyncSync = function(fd) { 
nbsp; return binding.fsync(fd); 
}; 
                         (编辑:滁州站长网) 
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! 
                     |