node.js中的fs.close方法使用說明
更新時間:2014年12月17日 10:37:19 投稿:junjie
這篇文章主要介紹了node.js中的fs.close方法使用說明,本文介紹了fs.close方法說明、語法、接收參數、使用實例和實現源碼,需要的朋友可以參考下
方法說明:
以異步的方式關閉文件。
語法:
復制代碼 代碼如下:
fs.close(fd, [callback(err)])
由于該方法屬于fs模塊,使用前需要引入fs模塊(var fs= require(“fs”) )
接收參數:
fd 文件open時傳遞的文件描述符。
callback 回調
例子:
復制代碼 代碼如下:
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');
});
});
});
源碼:
[code]
fs.close = function(fd, callback) {
binding.close(fd, makeCallback(callback));
};
[code]
相關文章
npm?install安裝失敗報錯:The?operation?was?rejected?by?your?
這篇文章主要給大家介紹了關于npm?install安裝失敗報錯:The?operation?was?rejected?by?your?operating?system的相關資料,文中給出了多種解決方法供大家參考學習,需要的朋友可以參考下2023-04-04
nodejs npm錯誤Error:UNKNOWN:unknown error,mkdir ''D:\Develop\n
今天小編就為大家分享一篇關于nodejs npm錯誤Error:UNKNOWN:unknown error,mkdir 'D:\Develop\nodejs\node_global'at Error,小編覺得內容挺不錯的,現在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03

