[b]方法说明: [/b]
以异步的方式关闭文件。
[b]语法:[/b]
fs.close(fd, [callback(err)])
由于该方法属于fs模块,使用前需要引入fs模块(var fs= require(“fs”) )
[b]接收参数:[/b]
fd 文件open时传递的文件描述符。
callback 回调
[b]例子:[/b]
var fs = require('fs');
fs.open('/path/demo1.txt', 'a', function (err, fd) {
if (err) {
throw err;
}
fs.futimes(fd, 1388648322, 1388648322, function (err) {
if (err) {
throw err;
}
console.log('futimes complete');
fs.close(fd, function () {
console.log('Done');
});
});
});
[b]源码:[/b]
[code]
fs.close = function(fd, callback) {
binding.close(fd, makeCallback(callback));
};
[code]