1. 程式人生 > >【指令碼語言】【RINGO JS】模組 fs

【指令碼語言】【RINGO JS】模組 fs

模組 fs

該模組提供了一個檔案系統API,用於處理路徑,目錄,檔案,連結以及輸入和輸出流的構造。 它遵循 CommonJS Filesystem/A 提議。

Example

// Writes a simple text file
var fs = require('fs');
if (!fs.exists('test.txt')) {
  var textStream = fs.open('test.txt', {
    write: true,
    binary: false
  });
  try {
    textStream.write('Hello World!');
    textStream.flush();
  } finally {
    textStream.close();
  }
  console.log('Wrote test.txt');
} else {
  console.error('test.txt already exists.');
}

Functions