DIV CSS 佈局教程網

Node.js 中 fs.fsyncSync 方法詳解與使用教學
編輯:關於JavaScript     

方法說明

fsync() 的同步版本,用來把作業系統的磁碟快取強制同步寫入實體儲存媒體,降低資料遺失風險。

語法

fs.fsyncSync(fd)

此方式屬於 fs 模組,使用前必須先引入:var fs = require("fs")

參數說明

fd:檔案描述符。

範例

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');
  });
});

原始碼

fs.fsyncSync = function(fd) {
  return binding.fsync(fd);
};
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved