Idris2/support/js/support_system_directory.js

64 lines
1.1 KiB
JavaScript
Raw Normal View History

const support_system_directory_fs = require("fs");
function support_system_directory_changeDir(d){
try{
2022-04-07 12:09:30 +03:00
process.chdir(d)
return 0
}catch(e){
2022-04-07 12:09:30 +03:00
process.__lasterr = e
return 1
}
}
function support_system_directory_createDir(d){
try{
support_system_directory_fs.mkdirSync(d)
return 0
}catch(e){
2022-04-07 12:09:30 +03:00
process.__lasterr = e
return 1
}
}
function support_system_directory_removeDir(d){
try{
support_system_directory_fs.rmdirSync(d)
return 0
}catch(e){
process.__lasterr = e
return 1
}
}
function support_system_directory_openDir(d) {
try{
return support_system_directory_fs.opendirSync(d)
}catch(e){
process.__lasterr = e
return null
}
}
function support_system_directory_closeDir(d) {
try{
d.closeSync()
}catch(e){
process.__lasterr = e
return null
}
}
function support_system_directory_dirEntry(d) {
try{
const dir = d.readSync()
if (dir == null) {
return null
} else {
return dir.name
}
}catch(e){
process.__lasterr = e
return null
}
}