clite.libs.data = function() { clite.libs.load('libclite','clite',function(io,env) { return Object.create({ // returns an absolute path: ('foo','/etc') -> '/etc/foo': ('foo','bar') -> $PWD/bar/foo resolvePath:function(txt,base) { if (txt == '/') return txt; if (txt[0] == '~') txt = env.HOME+txt.substring(1); if (txt[0] == '.') txt = env.PWD+'/'+txt; var path = txt; if (txt[0] != '/') { if (typeof base != 'string') base = env.PWD; if (base[0] != '/') base = env.PWD+'/'+base; path = base+'/'+txt; } var parts = path.split('/'); path = ''; var i; while ((i = parts.indexOf('.')) != -1) { parts.splice(i,1); } while ((i = parts.indexOf('')) != -1) { parts.splice(i,1); } while ((i = parts.indexOf('..')) != -1) { parts.splice(i-1,2); } path = '/'+parts.join('/'); return path; }, // convert a string into an argument array: 'ls /etc' -> ['ls','/etc'], supports "quoted arguments" and `command substitutions` strToArgs:function(txt) { var parts = []; var wasq = false; var sp = ''; var s = ''; var e = false; var q = false; var c = false; for (var i=0; i 0) parts.push(ss); parts.push(';'); }else{ parts.push(s); } s = ''; e = false; q = false; break; } default: s+=txt[i]; e = false; wasq = false; } } if (s.length > 0) { if (!wasq && s[s.length-1] == ';') { var ss = s.substring(0,s.length-1); if (ss.length > 0) parts.push(ss); parts.push(';'); }else{ parts.push(s); } } return parts; }, ptrnew:function() { return Object.create({value:null}); }, ptrset:function(ptr,val) { ptr.value = val; }, ptrget:function(ptr) { if (typeof ptr.value === 'undefined') return null; return ptr.value; }, strmode:function(mode) { return clite.lib.strmode(mode); }, modestr:function(perms) { return clite.lib.modestr(perms); }, cookienotice:function() { clite.io.write(io.pid,io.stdout,` The CLIte guest login does not use cookies. However CLIte does use cookies for custom user accounts, to store your account info, as well as the contents of your home directory. This way all of your personal data is kept on your own computer, rather than being uploaded to a random server somewhere. `); }, getcookiestate:function() { return clite.state.cookiesAccepted; }, setcookiestate:function(v) { if (typeof v == 'boolean') clite.state.cookiesAccepted = v; } }); }); }