Exemple #1
0
Object.keys(FS).forEach(function(name) {
	var source = null;
	var args = null;
	var index = -1;
	if (name === "open") {
		FileFS.prototype[name] = function() {
			var mode = "write";
			if (arguments[1] === "r" || arguments[1] === "rs") {
				mode = "read";
			}
			var meta = {};
			if (this._options.lineinfo) {
				var trace = STACK_TRACE.get();
			}
			this.notifyUsedPath(arguments[0], name + "-" + mode, meta);
			return FS[name].apply(null, arguments);
		};
	} else
	if (
		typeof FS[name] === "function" &&
		/^[a-z]/.test(name) &&
		(source = FS[name].toString()) &&
		(args = source.match(/function[^\(]+\(([^\)]*)\)/)[1].split(", ")) &&
		(
			(index = args.indexOf("path")) >= 0 ||
			(index = args.indexOf("dir")) >= 0 ||
			(index = args.indexOf("file")) >= 0 ||
			(index = args.indexOf("filename")) >= 0
		)
	) {
		FileFS.prototype[name] = function() {
			var meta = {};
			if (this._options.lineinfo) {
				var trace = STACK_TRACE.get();
				meta.file = trace[1].getFileName();
				meta.line = trace[1].getLineNumber();
			}
			this.notifyUsedPath(arguments[index], name, meta);
			var cb = arguments[arguments.length-1];
			if (typeof cb === "function" && name !== "exists") {
				arguments[arguments.length-1] = function(err) {
					if (err) {
						//console.error("[pinf-vfs-js] ERROR: While calling '" + name + "' for '" + arguments[index] + "'", err);
					}
					return cb.apply(null, arguments);
				}
			}
			try {
				return FS[name].apply(null, arguments);
			} catch(err) {
				//console.error("[pinf-vfs-js] ERROR: While calling '" + name + "' for '" + arguments[index] + "'", err);
				throw err;
			}
		};
	} else {
		FileFS.prototype[name] = FS[name];
	}
});
Exemple #2
0
		FileFS.prototype[name] = function() {
			var mode = "write";
			if (arguments[1] === "r" || arguments[1] === "rs") {
				mode = "read";
			}
			var meta = {};
			if (this._options.lineinfo) {
				var trace = STACK_TRACE.get();
			}
			this.notifyUsedPath(arguments[0], name + "-" + mode, meta);
			return FS[name].apply(null, arguments);
		};
Exemple #3
0
		FileFS.prototype[name] = function() {
			var meta = {};
			if (this._options.lineinfo) {
				var trace = STACK_TRACE.get();
				meta.file = trace[1].getFileName();
				meta.line = trace[1].getLineNumber();
			}
			this.notifyUsedPath(arguments[index], name, meta);
			var cb = arguments[arguments.length-1];
			if (typeof cb === "function" && name !== "exists") {
				arguments[arguments.length-1] = function(err) {
					if (err) {
						//console.error("[pinf-vfs-js] ERROR: While calling '" + name + "' for '" + arguments[index] + "'", err);
					}
					return cb.apply(null, arguments);
				}
			}
			try {
				return FS[name].apply(null, arguments);
			} catch(err) {
				//console.error("[pinf-vfs-js] ERROR: While calling '" + name + "' for '" + arguments[index] + "'", err);
				throw err;
			}
		};