comparison rlgwebd.js @ 81:e4773ac5d4d5

Switch to node v0.8. In node v0.8, path.exists() has been moved to the fs module.
author John "Elwin" Edwards <elwin@sdf.org>
date Sun, 08 Jul 2012 08:02:17 -0700
parents 57bf0dcd080e
children d59dc5cef412
comparison
equal deleted inserted replaced
80:7eb4cc9dfa94 81:e4773ac5d4d5
358 358
359 function checksaved(user, game, callback, args) { 359 function checksaved(user, game, callback, args) {
360 var savedirc = game.uname + "save"; 360 var savedirc = game.uname + "save";
361 var basename = String(dropToUID) + "-" + user + game.suffix; 361 var basename = String(dropToUID) + "-" + user + game.suffix;
362 var savefile = path.join("/var/games/roguelike", savedirc, basename); 362 var savefile = path.join("/var/games/roguelike", savedirc, basename);
363 path.exists(savefile, function (exist) { 363 fs.exists(savefile, function (exist) {
364 args.unshift(exist); 364 args.unshift(exist);
365 callback.apply(null, args); 365 callback.apply(null, args);
366 }); 366 });
367 } 367 }
368 368
743 nname = "index.html"; 743 nname = "index.html";
744 if (nname.match(/\/$/)) 744 if (nname.match(/\/$/))
745 path.join(nname, "index.html"); /* it was a directory */ 745 path.join(nname, "index.html"); /* it was a directory */
746 var realname = path.join(serveStaticRoot, nname); 746 var realname = path.join(serveStaticRoot, nname);
747 var extension = path.extname(realname); 747 var extension = path.extname(realname);
748 path.exists(realname, function (exists) { 748 fs.exists(realname, function (exists) {
749 var resheaders = {}; 749 var resheaders = {};
750 if (!exists || !extension || extension == ".html") 750 if (!exists || !extension || extension == ".html")
751 resheaders["Content-Type"] = "text/html; charset=utf-8"; 751 resheaders["Content-Type"] = "text/html; charset=utf-8";
752 else if (extension == ".png") 752 else if (extension == ".png")
753 resheaders["Content-Type"] = "image/png"; 753 resheaders["Content-Type"] = "image/png";
987 987
988 function shutdown () { 988 function shutdown () {
989 httpServer.close(); 989 httpServer.close();
990 httpServer.removeAllListeners('request'); 990 httpServer.removeAllListeners('request');
991 ctlServer.close(); 991 ctlServer.close();
992 fs.unlink(ctlsocket);
992 tslog("Shutting down..."); 993 tslog("Shutting down...");
993 process.exit(); 994 process.exit();
994 } 995 }
995 996
996 function conHandler(chunk) { 997 function conHandler(chunk) {