From bdd4b5c9fe6003d0410148a96aacea7dd8e91fd4 Mon Sep 17 00:00:00 2001 From: Petr Bouianov Date: Thu, 17 Apr 2014 19:22:20 -0400 Subject: [PATCH] Fixes issue #62 --- src/constants.js | 6 ++++++ src/filesystem/interface.js | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/constants.js b/src/constants.js index 660810f..6c6a59e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -68,6 +68,12 @@ define(function(require) { SUPER_NODE_ID: '00000000-0000-0000-0000-000000000000', + //Reserved FileDescriptors for streams + STDIN: 0, + STDOUT: 1, + STDERR: 2, + FIRST_DESCRIPTOR: 3, + ENVIRONMENT: { TMP: '/tmp', PATH: '' diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index 32e4053..cf8617d 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -19,6 +19,11 @@ define(function(require) { var FSWatcher = require('src/fs-watcher'); var Errors = require('src/errors'); + var STDIN = require('src/constants').STDIN; + var STDOUT = require('src/constants').STDOUT; + var STDERR = require('src/constants').STDERR; + var FD = require('src/constants').FIRST_DESCRIPTOR; + // The core fs operations live on impl var impl = require('src/filesystem/implementation'); @@ -74,10 +79,15 @@ define(function(require) { fs.name = name; fs.error = null; + fs.stdin = STDIN; + fs.stdout = STDOUT; + fs.stderr = STDERR; + fs.firstFD = FD; + // Safely expose the list of open files and file // descriptor management functions var openFiles = {}; - var nextDescriptor = 1; + var nextDescriptor = 3; Object.defineProperty(this, "openFiles", { get: function() { return openFiles; } });