summaryrefslogtreecommitdiff
path: root/src/loslib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 20:37:34 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 20:37:34 +1100
commitfadf3105964c5c65f06e9c561f4872be810080a9 (patch)
treecc8445162306b6368de737327c9f770e76fd67d1 /src/loslib.js
parentfe5682fe2e1647a4953cc8800bf497467816b441 (diff)
downloadfengari-fadf3105964c5c65f06e9c561f4872be810080a9.tar.gz
fengari-fadf3105964c5c65f06e9c561f4872be810080a9.tar.bz2
fengari-fadf3105964c5c65f06e9c561f4872be810080a9.zip
src/loslib.js: Remove to_jsstring where possible
Diffstat (limited to 'src/loslib.js')
-rw-r--r--src/loslib.js21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/loslib.js b/src/loslib.js
index 42723c8..745bbab 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -176,7 +176,9 @@ if (!WEB) {
};
syslib.getenv = function(L) {
- lua.lua_pushliteral(L, process.env[lua.to_jsstring(lauxlib.luaL_checkstring(L, 1))]); /* if NULL push nil */
+ let key = lauxlib.luaL_checkstring(L, 1);
+ key = lua.to_jsstring(key); /* https://github.com/nodejs/node/issues/16961 */
+ lua.lua_pushliteral(L, process.env[key]); /* if NULL push nil */
return 1;
};
@@ -193,10 +195,11 @@ if (!WEB) {
syslib.remove = function(L) {
let filename = lauxlib.luaL_checkstring(L, 1);
try {
- if (fs.lstatSync(lua.to_jsstring(filename)).isDirectory()) {
- fs.rmdirSync(lua.to_jsstring(filename));
+ filename = Uint8Array.from(filename);
+ if (fs.lstatSync(filename).isDirectory()) {
+ fs.rmdirSync(filename);
} else {
- fs.unlinkSync(lua.to_jsstring(filename));
+ fs.unlinkSync(filename);
}
} catch (e) {
return lauxlib.luaL_fileresult(L, false, filename, e);
@@ -205,9 +208,11 @@ if (!WEB) {
};
syslib.rename = function(L) {
- let fromname = lua.to_jsstring(lauxlib.luaL_checkstring(L, 1));
- let toname = lua.to_jsstring(lauxlib.luaL_checkstring(L, 2));
+ let fromname = lauxlib.luaL_checkstring(L, 1);
+ let toname = lauxlib.luaL_checkstring(L, 2);
try {
+ fromname = Uint8Array.from(fromname);
+ toname = Uint8Array.from(toname);
fs.renameSync(fromname, toname);
} catch (e) {
return lauxlib.luaL_fileresult(L, false, false, e);
@@ -228,7 +233,7 @@ if (!WEB) {
if (cmd !== null) {
try {
child_process.execSync(
- lua.to_jsstring(cmd),
+ Uint8Array.from(cmd),
{
stdio: [process.stdin, process.stdout, process.stderr]
}
@@ -241,7 +246,7 @@ if (!WEB) {
} else {
try {
child_process.execSync(
- lua.to_jsstring(cmd),
+ Uint8Array.from(cmd),
{
stdio: [process.stdin, process.stdout, process.stderr]
}