mirror of
https://codeberg.org/TicklishHoneyBee/CLIte.git
synced 2026-03-11 09:04:37 +00:00
118 lines
2.2 KiB
JavaScript
118 lines
2.2 KiB
JavaScript
clite.libs.data = function() {
|
|
|
|
clite.libs.load('libio','stdio',function(io,env) {
|
|
|
|
return Object.create({
|
|
|
|
types:clite.io.types,
|
|
flags:clite.io.flags,
|
|
|
|
creat:function(path,type) {
|
|
return clite.io.creat(io.pid,path,type);
|
|
},
|
|
|
|
open:function(path,flags,cb) {
|
|
return clite.io.open(io.pid,path,flags,cb);
|
|
},
|
|
|
|
close:function(fd) {
|
|
return clite.io.close(io.pid,fd);
|
|
},
|
|
|
|
read:function(fd,cb) {
|
|
return clite.io.read(io.pid,fd,cb);
|
|
},
|
|
|
|
readLine:function(fd,cb) {
|
|
return clite.io.readLine(io.pid,fd,cb);
|
|
},
|
|
|
|
readAll:function(fd) {
|
|
return clite.io.readAll(io.pid,fd);
|
|
},
|
|
|
|
write:function(fd,data) {
|
|
return clite.io.write(io.pid,fd,data);
|
|
},
|
|
|
|
ftruncate:function(fd,len) {
|
|
return clite.io.ftruncate(io.pid,fd,len);
|
|
},
|
|
|
|
truncate:function(path,len) {
|
|
return clite.io.truncate(io.pid,path,len);
|
|
},
|
|
|
|
seek:function(fd,pos) {
|
|
return clite.io.seek(io.pid,fd,pos);
|
|
},
|
|
|
|
remove:function(path) {
|
|
return clite.io.remove(io.pid,path);
|
|
},
|
|
|
|
link:function(path,target) {
|
|
return clite.io.link(io.pid,path,target);
|
|
},
|
|
|
|
fstatat:function(fd,flags) {
|
|
return clite.io.fstatat(io.pid,fd,flags);
|
|
},
|
|
|
|
stat:function(path) {
|
|
var fd = clite.io.open(io.pid,path,clite.io.flags.O_RDONLY);
|
|
if (!fd)
|
|
return null;
|
|
var st = clite.io.fstatat(io.pid,fd,0);
|
|
clite.io.close(io.pid,fd);
|
|
return st;
|
|
},
|
|
|
|
lstat:function(path) {
|
|
var fd = clite.io.open(io.pid,path,clite.io.flags.O_RDONLY|clite.io.flags.O_NOFOLLOW);
|
|
if (!fd)
|
|
return null;
|
|
var st = clite.io.fstatat(io.pid,fd,clite.io.flags.AT_SYMLINK_NOFOLLOW);
|
|
clite.io.close(io.pid,fd);
|
|
return st;
|
|
},
|
|
|
|
chmod:function(path,mode) {
|
|
return clite.io.chmod(io.pid,path,mode);
|
|
},
|
|
|
|
fchmod:function(fd,mode) {
|
|
return clite.io.fchmod(io.pid,fd,mode);
|
|
},
|
|
|
|
isatty:function(fd) {
|
|
return clite.io.isatty(io.pid,fd);
|
|
},
|
|
|
|
mkdir:function(path,mode) {
|
|
return clite.io.mkdir(io.pid,path,mode);
|
|
},
|
|
|
|
vfprintf:function(fd,fmt,args) {
|
|
return clite.io.vfprintf(io.pid,fd,fmt,args);
|
|
},
|
|
|
|
fprintf:function(fd,fmt) {
|
|
var args = Array.from(arguments);
|
|
args.shift();
|
|
args.shift();
|
|
return clite.io.vfprintf(io.pid,fd,fmt,args);
|
|
},
|
|
|
|
printf:function(fmt) {
|
|
var args = Array.from(arguments);
|
|
args.shift();
|
|
return clite.io.vfprintf(io.pid,io.stdout,fmt,args);
|
|
}
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|