# HG changeset patch # User John "Elwin" Edwards # Date 1485549790 18000 # Node ID 04c2a895b6791f02e742c18bcedb8f7a2fca5eb3 # Parent 6651f54a006293703d6493f86ac7f58d7b27897d RLGWebD: replace deprecated fs.exists() with fs.access(). diff -r 6651f54a0062 -r 04c2a895b679 rlgwebd --- a/rlgwebd Thu Jan 12 19:02:20 2017 -0500 +++ b/rlgwebd Fri Jan 27 15:43:10 2017 -0500 @@ -486,8 +486,11 @@ var savedirc = game.uname + "save"; var basename = String(pwent.uid) + "-" + user + game.suffix; var savefile = path.join("/var/games/roguelike", savedirc, basename); - fs.exists(savefile, function (exist) { - args.unshift(exist); + fs.access(savefile, function (err) { + if (err) + args.unshift(false); + else + args.unshift(true); callback.apply(null, args); }); } @@ -838,9 +841,9 @@ path.join(nname, "index.html"); /* it was a directory */ var realname = path.join(rlgwebd_options.static_root, nname); var extension = path.extname(realname); - fs.exists(realname, function (exists) { + fs.access(realname, function (access_err) { var resheaders = {}; - if (!exists || !extension || extension == ".html") + if (access_err || !extension || extension == ".html") resheaders["Content-Type"] = "text/html; charset=utf-8"; else if (extension == ".png") resheaders["Content-Type"] = "image/png"; @@ -852,7 +855,7 @@ resheaders["Content-Type"] = "image/svg+xml"; else resheaders["Content-Type"] = "application/octet-stream"; - if (exists) { + if (!access_err) { fs.readFile(realname, function (error, data) { if (error) { res.writeHead(500, {});