Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

start of filesystem module writen

  • Loading branch information...
commit 14442c45cb89d6ed74de9b1820101100d3204097 1 parent b00f1cc
@matthewfl matthewfl authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 sandbox/modules.js
View
36 sandbox/modules.js
@@ -85,4 +85,40 @@ exports.db = exports.database = function (context, config) {
db.has(baseName+name, back);
}
};
+};
+
+exports.fs = function (context, config) {
+ db = db || require('../db');
+ var baseName = "fs_"+config.user+"_";
+ function noMod () {
+ throw "The filesystem supports no modifications of the file system from the application";
+ }
+ function noSync () {
+ throw "The file system supports not synchronous calls";
+ }
+ return {
+ unlink: noMod,
+ unlinkSync: noSync,
+ rename: noMod,
+ renameSync: noSync,
+ truncate: noMod,
+ truncateSync: noSync,
+ chmod: noMod,
+ chmodSync: noSync,
+ stat: function () {},
+ lstat: function () {},
+ fstat: function () {},
+ statSync: noSync,
+ lstatSync: noSync,
+ fstatSync: noSync,
+ link: noMod,
+ linkSync: noSync,
+
+ readFile: function(name, encoding, back) {
+ db.get(baseName+name.replace(/(\.[\/\\]+)*([a-zA-Z0-9\.]+)/, "$2"), function (b) {
+ (typeof encoding == "function" ? encoding : back)(b == null ? "error" : null, b);
+ });
+ }
+
+ };
};
Please sign in to comment.
Something went wrong with that request. Please try again.