File System

The fs module provides an API for interacting with the file system in a manner closely modeled around standard POSIX functions.

Goal of this inerface is to be compatible with Node.js File System API

Compatibility objective : 80%

To use this module:

const fs = require('fs');

All file system operations have synchronous and asynchronous forms.


Compatibility : broken

Open, read and return text content of a file. It will throw an exception if it fails.

  • path <string> Path of the file to read from
  • Returns : Contents of the file
let data = fs.readFile('/etc/passwd');'Data : {0}', data);

fs.readdirSync(path, options)

Synchronous readdir(3).

  • path <string> Path of the directory
  • options <object> Options
  • Returns : An array of filenames excluding ‘.’ and ‘..’


Synchronous stat(2). Returns an instance of fs.Stats.

Class : fs.Stats

A fs.Stats object provides information about a file.


Returns true if the fs.Stats object describes a file system directory.


Returns true if the fs.Stats object describes a regular file.

Returns true if the fs.Stats object describes a symbolic link.

  • <number> The numeric identifier of the device containing the file.


  • <number> The file system specific “Inode” number for the file.


  • <number> A bit-field describing the file type and mode.
  • <number> The number of hard-links that exist for the file.


  • <number> The numeric user identifier of the user that owns the file (POSIX).


  • <number> The size of the file in bytes.


  • <number> The number of blocks allocated for this file.


  • Add support for Promises
  • Fix broken API