Idris2/support/js/support_system_directory.js
Niklas Larsson b32a2593ff Node fixes
Don't assume that errno exists. There might never have been an error.

Quote executable path to handle path with spaces.
2021-04-12 16:43:54 +02:00

30 lines
542 B
JavaScript

const support_system_directory_fs = require("fs")
function support_system_directory_fileErrno(){
const n = process.__lasterr.errno || 0;
switch(n){
case -17: return 4n;
default: return -BigInt(n)
}
}
function support_system_directory_changeDir(d){
try{
process.chdir(d);
return 0n
}catch(e){
process.__lasterr = e;
return 1n
}
}
function support_system_directory_createDir(d){
try{
support_system_directory_fs.mkdirSync(d)
return 0n
}catch(e){
process.__lasterr = e;
return 1n
}
}