PDP-11 command-line (Node-based) operation is finally working

This commit is contained in:
Jeff Parsons 2016-12-30 14:51:32 -08:00 committed by Jeff Parsons
commit 4b345bb3d2
19 changed files with 552 additions and 438 deletions

View file

@ -310,23 +310,25 @@ class Net {
* @param {string} sURL
* @param {Object|null} [dataPost] for a POST request (default is a GET request)
* @param {boolean} [fAsync] is true for an asynchronous request
* @param {function(string,string,number)} [done]
* @param {function(string,string|null,number)} [done]
* @return {Array|null} Array containing [sResource, nErrorCode], or null if no response yet
*/
static getResource(sURL, dataPost, fAsync, done)
{
var nErrorCode = -1, sResource = null, response = null;
/*
* TODO: Revisit why we pass back sBaseName instead of the original sURL....
*/
var sBaseName = Str.getBaseName(sURL);
if (Net.isRemote(sURL)) {
console.log('Net.getResource("' + sURL + '"): unimplemented');
if (done) done(sBaseName, null, -1);
} else {
if (!Net.sServerRoot) {
Net.sServerRoot = path.join(path.dirname(fs.realpathSync(__filename)), "../../../");
}
/*
* TODO: Revisit why we pass back sBaseName instead of the original sURL....
*/
var sBaseName = Str.getBaseName(sURL);
var sFile = path.join(Net.sServerRoot, sURL);
if (fAsync) {
fs.readFile(sFile, {encoding: "utf8"}, function(err, s)