diff --git a/clite/commands.js b/clite/commands.js index fa333e8..507c736 100644 --- a/clite/commands.js +++ b/clite/commands.js @@ -495,7 +495,7 @@ clite.commands.load('rm',function(args,env,io) { function help() { stdio.printf(` rm - remove files or directories -Usage: file [OPTION] +Usage: rm [OPTION] Options: -r Remove directories and their contents recusively @@ -588,6 +588,86 @@ Options: return removeFile(file); }); +clite.commands.load('mkdir',function(args,env,io) { + var short = null; + var file = null; + var stdio = io.include('stdio'); + var stdlib = io.include('stdlib'); + var clite = io.include('clite'); + var recurse = false; + function help() { + stdio.printf(` +mkdir - remove files or directories +Usage: mkdir [OPTION] + +Options: +-p Make the full path, not just the final directory +-? Print this help information + `); + } + + for (var i=1; i 10) + mode = 'drwxr-xr-x'; + if (mode.length == 9) + mode = 'd'+mode; + if (mode[0] != 'd') + mode = 'd'+mode.substring(0,9); + var uid = clite.proc.getUID(pid); + var r = vfsapi.mkDir(uid,path); + if (!r) + return false; + var n = vfsapi.getNode(uid,path); + if (!n) + return false; + n.perms = mode; + return true; + } + clite.io.vfprintf = function(pid,fd,fmt,args) { var str = ''; var parts = fmt.replace(/%%/g,'%').split('%'); @@ -1576,6 +1594,7 @@ clite.io = { chmod:null, fchmod:null, isatty:null, + mkdir:null, vfprintf:null }; diff --git a/clite/libstdio.js b/clite/libstdio.js index b3613f4..e543d60 100644 --- a/clite/libstdio.js +++ b/clite/libstdio.js @@ -74,6 +74,10 @@ return Object.create({ 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); },